一个字符串加密的代码,自己看不懂,就是自己输入密码后进行加密,具体的每一步看不懂,请高手解释一下,谢谢了~~
Public Sub getseed(password)
Seedlong = Len(password)
For i = 1 To Seedlong
Seed(i) = Asc(Mid(password, i, 1)) Xor i
Next i
If Form2.CheEnter.value = 1 Then pass.BEenter = True Else pass.BEenter = False
If Form2.CheKong.value = 1 Then pass.BEenter = True Else pass.BKong = False
End Sub
Public Sub mi()
temp = ""
Dim intlen
Dim latter
intForm = intForm + 1
intTo = intTo + 1
intlen = Len(Form1.Text1)
z1 = Mid(Form1.Text1.Text, 1, intForm - 1)
z2 = Mid(Form1.Text1.Text, intForm, intTo - intForm)
z3 = Mid(Form1.Text1.Text, intTo + 1, intlen)
a = Len(z2)
For i = 0 To a Step Seedlong
For j = 1 To Seedlong
On Error GoTo c
latter = Asc(Mid(z2, i + j, 1))
If latter = 32 And pass.BEenter = True Then GoTo b Else GoTo a
If latter = 13 And pass.BKong = True Then GoTo b Else GoTo a
a: latter = Seed(j) Xor Asc(Mid(z2, i + j, 1))
b: temp = temp & Chr(latter)
Next j
c: Next i
Form1.Text1.Text = z1 & temp & z3
End Sub
Public Sub getseed(password) 'password为加密字符串的密码
Seedlong = Len(password) '获得长度
For i = 1 To Seedlong '取得密码每一位
Seed(i) = Asc(Mid(password, i, 1)) Xor i 对密码进行加密,分别与位异或
Next i
If Form2.CheEnter.value = 1 Then pass.BEenter = True Else pass.BEenter = False 是否加密回车
If Form2.CheKong.value = 1 Then pass.BEenter = True Else pass.BKong = False 是否加密空格
End Sub
Public Sub mi()
temp = ""
Dim intlen
Dim latter
intForm = intForm + 1 加密字符串的开始位置
intTo = intTo + 1 加密字符串的结束位置
intlen = Len(Form1.Text1) 总长度
z1 = Mid(Form1.Text1.Text, 1, intForm - 1) 加密字符串前面的字符
z2 = Mid(Form1.Text1.Text, intForm, intTo - intForm) 待加密的字符串
z3 = Mid(Form1.Text1.Text, intTo + 1, intlen) 加密字符串后面的字符
a = Len(z2) 待加密的字符串长度
For i = 0 To a Step Seedlong 取得待加密字符串的每一位
For j = 1 To Seedlong 按密码长度分组加密
On Error GoTo c 容错代码
latter = Asc(Mid(z2, i + j, 1)) 取得每一位
If latter = 32 And pass.BEenter = True Then GoTo b Else GoTo a 是否加密空格
If latter = 13 And pass.BKong = True Then GoTo b Else GoTo a 是否加密回车
a: latter = Seed(j) Xor Asc(Mid(z2, i + j, 1)) 每一位分别与加密后的密码异或
b: temp = temp & Chr(latter) 重新组合
Next j
c: Next i
Form1.Text1.Text = z1 & temp & z3 放回到原来位置
End Sub