如何加密文本文件,又不需要改变文件的内容。并且加密后,文件仍能剪切至其他目录。
解决方案 »
- 请教关于参数传递的问题
- vaSpread和fpSpread有什么区别啊?
- ~~~~~~~~~~~数据库连接问题~~~~~~~~~~~~
- 如何利用picturebox 控件动态生成曲线图?(急,急,急)
- 懂COM的高手来看!!
- ◆◆◆发现 VB6里面 超级离谱的 BUG !!!!!! 对VB感到气愤和失望 ◆◆◆
- 如何令MSHFlexGrid显示最后一行?
- 新手求助!
- MMControl逐帧播放时出现跳帧情况?
- 技术交友---诚邀有WebClass开发IIS应用程序经验的同行为友!为表诚意,坚决送分!
- 统计列总和语句错//拜托;高手请进在看看到底错在哪里没答案
- /*****************vb连接internet上sql server数据库的问题****************/
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
--------
改写操作系统,只允许对这些文本文件剪切,而不能打开.
对于同样水平的用户,你只需要把注册表里文本文件的默认打开程序设为MSPAINT就可以了.