Encryption/Decryption process works well
Encryption/Decryption process works well
API Declarations
'put 3 text boxes on a form
'and 2 command buttons
'put them in whatever layout you choose
'text1 is where the user puts in the text to be encrypted
'text2 is where the user puts in the encryption key
'text3 is where the encrypted text is put
'command1 is the encrypt button
'command2 is the decrypt button
'not the best code, but will work
'--------------------------
' brad23
'--------------------------
' www.brad23hacks.f2s.com
'--------------------------
'[email protected]
'--------------------------
Rate Encryption/Decryption process works well
(1(1 Vote))
Message = Text1.Text
Key = Text2.Text
For i = 1 To Len(Message)
If Text2.Text = "" Then GoTo brad
textChar = Mid(Message, i, 1)
keyChar = Mid(Key, (i Mod Len(Key)) + 1)
encryptedChar = Asc(textChar) Xor Asc(keyChar)
EncryptedMessage = EncryptedMessage & Chr(encryptedChar)
Next
Text3.Text = EncryptedMessage
GoTo past
brad:
MsgBox ("Please enter an Encryption Key")
past:
End Sub
Private Sub Command2_Click()
MsgBox ("Your decrypted message will appear in the first box")
after:
Message = Text3.Text
Key = Text2.Text
For i = 1 To Len(Message)
textChar = Mid(Message, i, 1)
keyChar = Mid(Key, (i Mod Len(Key)) + 1)
encryptedChar = Asc(textChar) Xor Asc(keyChar)
EncryptedMessage = EncryptedMessage & Chr(encryptedChar)
Next
Text1.Text = EncryptedMessage
End Sub
Encryption/Decryption process works well Comments
No comments yet — be the first to post one!
Post a Comment