by Amplify (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 7th September 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Encrypting With Keyword
API Declarations
Dim Current_Letter As String
Dim Encrypted_Phase1 As Long
Dim Encrypted_Phase2 As Long
Dim Encrypted_Word As String
For Letter_Count = 1 To Len(Not_Encrypted_Txt)
Current_Letter = Mid$(Not_Encrypted_Txt, Letter_Count, 1)
Encrypted_Phase1 = Asc(Current_Letter) - 1
Encrypted_Phase2 = Encrypted_Phase1 + Asc(Mid$(Key_Word, Letter_Count, 1))
Encrypted_Word = Encrypted_Word + Chr$(Encrypted_Phase2)
Next Letter_Count
Encode = Encrypted_Word
End Function
Public Function Decode(ByVal Encrypted_Txt As String, Key_Word As String)
For Letter_Count = 1 To Len(Encrypted_Txt)
Current_Letter = Mid$(Encrypted_Txt, Letter_Count, 1)
Encrypted_Phase1 = Asc(Current_Letter) - Asc(Mid$(Key_Word, Letter_Count, 1))
Encrypted_Phase2 = Encrypted_Phase1 + 1
Encrypted_Word = Encrypted_Word + Chr$(Encrypted_Phase2)
Next Letter_Count
Decode = Encrypted_Word
End Function
If Len(Txt_To_Encrypt.Text) = Len(Key_Word_Given.Text) Then
Txt_Encrypted.Text = Encode(Txt_To_Encrypt.Text, Key_Word_Given.Text)
Else
MsgBox "Keyword should be exact the account of letters" & vbCrLf & "as the text that is going to be encrypted", vbOKOnly
End If
End Sub
Private Sub Unecrypt_Button_Click()
Txt_Unencrypted.Text = Decode(Txt_Encrypted.Text, Key_Word_Given.Text)
End Sub