
(2)需求采用运算符XOR,至少要比程序中增加使用三个控件对象
(3)综合运用多种文件控件
(4)对文件中的字符采用逐字加密解密的方法
看看这个,控件要自己添加的
在窗体上添加文汪物件控件:Drive控件,Dir控件蠢缺,File控件,带陵辩以及Command控件
程序过程:每次用Xor加密解密后,在文件名加上前缀X-,然后另外保存
Private Sub Command1_Click()
Dim oldFile As String, newfile As String, theByte As Byte
If File1.FileName = "" Then MsgBox "请选择需要加密或解密的文件!": Exit Sub
oldFile = Dir1.Path & "\" & File1.FileName
newfile = Dir1.Path & "\X-" & File1.FileName
Open oldFile For Binary As #1 Len = 1
Open newfile For Binary As #2
Do
Get #1, , theByte
theByte = 7 Xor theByte
Put #2, , theByte
Loop Until EOF(1)
Close #1
Close #2
MsgBox "加密或解密后的文件存放在“" & newfile & "”中!"
File1.Refresh
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Form_Load()
File1.Pattern = "*.txt" '只列出txt文本文件,如果要列出全部文件,改成*.*
Command1.Caption = "加密解密"
End Sub
Get #1, , theByte
theByte = 7 Xor theByte
Put #2, , theByte
这里用了7,可以碧李拆换成别的数字吗,不过真的很喜欢你给扰键的这些程序,希望解答悔枣,谢谢
这题目居然没分?