如何加密文本文件,又不需要改变文件的内容。并且加密后,文件仍能剪切至其他目录。

解决方案 »

  1.   

    最简单的方法是用rar加密压缩
      

  2.   

    先把汉字全部转换成拼音,然后再把拼音转换成 ascll码 呵呵,菜鸟办法
      

  3.   

    但是我的文件里是GBK码,BIG5码和SHIFT-JIS码
      

  4.   

    你用这个吧需要加入 text1 和 按钮1   然后复制下面代码Option Explicit
      Dim charlist     As String
      Private Function Base64encode(ByVal s As String) As String
            Dim ByteArray()     As Byte
            ByteArray = StrConv(s, vbFromUnicode)         '将字串转为byte数组
            Dim tempstr     As String
            Dim stemp     As String
            Dim i     As Long
            Dim j     As Long, k       As Long
            Dim num1     As Long, num2       As Long, num3       As Long, num4       As Long
            i = UBound(ByteArray)
            i = (i + 1) Mod 3
            Select Case i
            Case 0
                      If s = vbNullString Then
                              Base64encode = ""
                              Exit Function
                      End If
                      For j = 0 To UBound(ByteArray) Step 3
                              num1 = ByteArray(j) \ 2 ^ 2               '右移2位,即取前6位
                              num2 = (ByteArray(j) And 3) * 2 ^ 4 + ByteArray(j + 1) \ 2 ^ 4
                              num3 = (ByteArray(j + 1) And 15) * 2 ^ 2 + ByteArray(j + 2) \ 2 ^ 6
                              num4 = ByteArray(j + 2) And 63
                              stemp = Mid(charlist, num1 + 1, 1) & Mid(charlist, num2 + 1, 1) & Mid(charlist, num3 + 1, 1) & Mid(charlist, num4 + 1, 1)
                              tempstr = tempstr + stemp
                      Next
            Case 1
                      For j = 0 To UBound(ByteArray) - 1 Step 3
                              num1 = ByteArray(j) \ 2 ^ 2               '右移2位,即取前6位
                              num2 = (ByteArray(j) And 3) * 2 ^ 4 + ByteArray(j + 1) \ 2 ^ 4
                              num3 = (ByteArray(j + 1) And 15) * 2 ^ 2 + ByteArray(j + 2) \ 2 ^ 6
                              num4 = ByteArray(j + 2) And 63
                              stemp = Mid(charlist, num1 + 1, 1) & Mid(charlist, num2 + 1, 1) & Mid(charlist, num3 + 1, 1) & Mid(charlist, num4 + 1, 1)
                              tempstr = tempstr + stemp
                      Next
                      '处理数组的最后1个元素
                      k = UBound(ByteArray)
                      num1 = ByteArray(k) \ 2 ^ 2
                      num2 = (ByteArray(k) And 3) * 2 ^ 4
                      stemp = Mid(charlist, num1 + 1, 1) & Mid(charlist, num2 + 1, 1) & "=="
                      tempstr = tempstr + stemp
            Case 2
                      For j = 0 To UBound(ByteArray) - 2 Step 3
                              num1 = ByteArray(j) \ 2 ^ 2               '右移2位,即取前6位
                              num2 = (ByteArray(j) And 3) * 2 ^ 4 + ByteArray(j + 1) \ 2 ^ 4
                              num3 = (ByteArray(j + 1) And 15) * 2 ^ 2 + ByteArray(j + 2) \ 2 ^ 6
                              num4 = ByteArray(j + 2) And 63
                              stemp = Mid(charlist, num1 + 1, 1) & Mid(charlist, num2 + 1, 1) & Mid(charlist, num3 + 1, 1) & Mid(charlist, num4 + 1, 1)
                              tempstr = tempstr + stemp
                      Next
                      '处理数组的最后2个元素
                      k = UBound(ByteArray)
                      num1 = ByteArray(k - 1) \ 2 ^ 2                   '右移2位,即取前6位
                      num2 = (ByteArray(k - 1) And 3) * 2 ^ 4 + ByteArray(k) \ 2 ^ 4
                      num3 = (ByteArray(k) And 15) * 2 ^ 2
                      stemp = Mid(charlist, num1 + 1, 1) & Mid(charlist, num2 + 1, 1) & Mid(charlist, num3 + 1, 1) & "="
                      tempstr = tempstr + stemp
            End Select
              
            Base64encode = tempstr
      End Function
        
          Private Sub Command1_Click()
        
             MsgBox Base64encode(Text1.Text)
        
      End Sub
        
      Private Sub Form_Load()
              charlist = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
      End Sub
      

  5.   

    异或运算,MS 的ACCESS也是这样的
      

  6.   

    如何加密文本文件,又不需要改变文件的内容。并且加密后,文件仍能剪切至其他目录。
    --------
    改写操作系统,只允许对这些文本文件剪切,而不能打开.
    对于同样水平的用户,你只需要把注册表里文本文件的默认打开程序设为MSPAINT就可以了.