# 加密与解密

Posted by 彭明柳 on June 05, 1998 at 14:01:15:

In Reply to: 存档格式 posted by Atony on June 05, 1998 at 02:26:19:

试看看以下加密与解密的简单演算法

Public Function Crypt(texti, salasana)
For T = 1 To Len(salasana)
sana = Asc(Mid(salasana, T, 1))
X1 = X1 + sana
Next
X1 = Int((X1 * 0.1) / 6)
salasana = X1
G = 0
For TT = 1 To Len(texti)
sana = Asc(Mid(texti, TT, 1))
G = G + 1
If G = 6 Then G = 0
X1 = 0
If G = 0 Then X1 = sana - (salasana - 2)
If G = 1 Then X1 = sana + (salasana - 5)
If G = 2 Then X1 = sana - (salasana - 4)
If G = 3 Then X1 = sana + (salasana - 2)
If G = 4 Then X1 = sana - (salasana - 3)
If G = 5 Then X1 = sana + (salasana - 5)
X1 = X1 + G
Crypted = Crypted & Chr(X1)
Next
Form1.Text1 = Crypted
End Function

Public Function DeCrypt(texti, salasana)
For T = 1 To Len(salasana)
sana = Asc(Mid(salasana, T, 1))
X1 = X1 + sana
Next
X1 = Int((X1 * 0.1) / 6)
salasana = X1
G = 0
For TT = 1 To Len(texti)
sana = Asc(Mid(texti, TT, 1))
G = G + 1
If G = 6 Then G = 0
X1 = 0
If G = 0 Then X1 = sana + (salasana - 2)
If G = 1 Then X1 = sana - (salasana - 5)
If G = 2 Then X1 = sana + (salasana - 4)
If G = 3 Then X1 = sana - (salasana - 2)
If G = 4 Then X1 = sana + (salasana - 3)
If G = 5 Then X1 = sana - (salasana - 5)
X1 = X1 - G
DeCrypted = DeCrypted & Chr(X1)
Next
Form1.Text1 = DeCrypted
End Function

' 'Finish Quality !!!
' 'mail me to jouni.vuorio@vtoy.fi
' 'algorithm copyright 1997 jouni vuorio

Follow Ups: