by Khaldoun Baz (12 Submissions)
Category: String Manipulation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 11th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Simple code to Crypt UnCrypt string using a key
If Command1.Caption = "Crypt" Then
Command1.Caption = "UnCrypt"
Else
Command1.Caption = "Crypt"
End If
Text1.Text = CryptIt(Text1.Text, Text2.Text)
End Sub
Private Function CryptIt(ToCrypt As String, CryptString As String)
Dim PosS As Long, PosC As Long, TempString As String
TempString = Space$(Len(ToCrypt))
PosC = 1
For PosS = 1 To Len(ToCrypt)
If PosC > Len(CryptString) Then PosC = 1
Mid(TempString, PosS, 1) = Chr$(Asc(Mid(ToCrypt, PosS, 1)) Xor Asc(Mid(CryptString, PosC, 1)))
If Asc(Mid(TempString, PosS, 1)) = 0 Then Mid(TempString, PosS, 1) = Mid(ToCrypt, PosS, 1)
PosC = PosC + 1
Next PosS
CryptIt = TempString
End Function