VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Simple code to Crypt UnCrypt string using a key

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

Rate 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



Download this snippet    Add to My Saved Code

Simple code to Crypt UnCrypt string using a key Comments

No comments have been posted about Simple code to Crypt UnCrypt string using a key. Why not be the first to post a comment about Simple code to Crypt UnCrypt string using a key.

Post your comment

Subject:
Message:
0/1000 characters