usrcryption.bas
来自「这是一个用vb 写的聊天室」· BAS 代码 · 共 97 行
BAS
97 行
Attribute VB_Name = "UsrCryption"
Public Function Encrypt(What, Key)
Dim Password As String
Dim Words As String
Dim Encrypted As String
Dim Tempchar As String
Dim Tempchar1 As String
Dim Counter As Integer
Dim TempAsc As Integer
Dim TempAsc1 As Integer
Counter = 1
Password = Key
Words = What
For X = 1 To Len(Words) 'loop for each letter of the password
Tempchar1 = Mid(Password, Counter, 1) 'get a Single letter of the password
Tempchar = Mid(Words, X, 1) 'get a Single letter of the words
TempAsc = Asc(Tempchar) 'convert the letter of the word to a number
TempAsc1 = Asc(Tempchar1) 'convert the letter of the password to a number
TempAsc = TempAsc - TempAsc1 ' subtract the two values
'check to see if the value if greater then 245. if it is, subtrac
' t 245 from it.
'this makes sure that we don't go past the highest ascii value
If TempAsc < 0 Then TempAsc = TempAsc + 245
Tempchar = Chr(TempAsc) 'convert the number back to a character
'add the character to the end of the encrypted string
Encrypted = Encrypted & Tempchar
Counter = Counter + 1 'incriment the counter
'check to see if the counter is > the length of the password
'if it is, set the counter to 1
If Counter > Len(Password) Then Counter = 1
Next X
Encrypt = Encrypted
End Function
Public Function Decrypt(What, Key)
Dim Password As String
Dim Words As String
Dim Encrypted As String
Dim Counter As Integer
Dim Tempchar As String
Counter = 1
Password = Key
Words = What
For X = 1 To Len(Words) 'loop for each letter of the password
Tempchar1 = Mid(Password, Counter, 1) 'get a Single letter of the password
Tempchar = Mid(Words, X, 1) 'get a Single letter of the words
TempAsc = Asc(Tempchar) 'convert the letter of the password to a number
TempAsc1 = Asc(Tempchar1) 'convert the letter of the word to a number
TempAsc = TempAsc + TempAsc1 ' add the two values
'check to see if the value if greater then 245. if it is, subtrac
' t 245 from it.
'this makes sure that we don't go past the highest ascii value
If TempAsc > 245 Then TempAsc = TempAsc - 245
Tempchar = Chr(TempAsc) 'convert the number back to a character
Encrypted = Encrypted & Tempchar 'add the character to the End of the encrypted String
Counter = Counter + 1 'incriment the counter
'check to see if the counter is > the length of the password
'if it is, set the counter to 1
If Counter > Len(Password) Then Counter = 1
Next X
'show the encoded text in the textbox
Decrypt = Encrypted
End Function
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?