Info

Decrypt

Private Sub cmdDecrypt_Click()

Dim sDecryptedMessage As String Dim sDecryptedCharacter As String Dim iCounter As Integer

If txtMessage.Value <> "" Then

' Iterate through each encrypted character in the message. For iCounter = 1 To Len(txtMessage.Value)

' Convert one encrypted character at a time to its ' equivalent character code.

sDecryptedCharacter = Asc(Mid(txtMessage.Value, iCounter, 1))

' Convert the character code (shifted by -1) back ' to a character.

sDecryptedCharacter = Chr(sDecryptedCharacter - 1)

' Add the decrypted character to the new decrypted message. sDecryptedMessage = sDecryptedMessage + sDecryptedCharacter

Next iCounter

' Display the decrypted message. txtMessage.Value = sDecryptedMessage

End If

End Sub

Private Sub cmdEncrypt_Click()

Dim sEncryptedMessage As String Dim sEncryptedCharacter As String Dim iCounter As Integer

If txtMessage.Value <> "" Then

' Iterate through each character in the message. For iCounter = 1 To Len(txtMessage.Value)

' Convert one character at a time to its equivalent ' character code.

sEncryptedCharacter = Asc(Mid(txtMessage.Value, iCounter, 1))

' Convert the character code (shifted by 1) back ' to a character.

sEncryptedCharacter = Chr(sEncryptedCharacter + 1)

' Add the encrypted character to the new encrypted message. sEncryptedMessage = sEncryptedMessage + sEncryptedCharacter

Next iCounter

' Display the encrypted message. txtMessage.Value = sEncryptedMessage

End If End Sub

0 0

Post a comment