VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Encrypts text

by john tomson (9 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sun 13th November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Encrypts text

Rate Encrypts text



    pass$ = Len(password.Text) 'the number you shift Each letter To encrypt
    tmpstr = Len(Text1.Text)


    If tmpstr = "0" Then
        MsgBox ("You must first Type In something To Encrypt") 'You can't encrypt nothing
        Exit Sub
    End If


    For i = 1 To tmpstr
        letter = Mid$(Text1.Text, i, 1) 'takes the ascii value and adds the length of the password To it
        encstr = Asc(letter) + pass$
        newstr = Chr$(encstr) 'changes ascii value To a character
        encrypted$ = encrypted$ & newstr 'puts all the encrypted characters together
    Next i
    Text1.Text = encrypted$ 'puts the encrypted String in text box
End Sub


Private Sub cmdDecrypt_Click()
    pass$ = Len(password.Text) 'this is the exact same For the Encrypt Function
    tmpstr = Len(Text1.Text) 'the only difference is that instead of adding the lenght of password.text
    'it is subtracted


    If tmpstr = "0" Then
        MsgBox ("You must first Type In something To Decrypt")
        Exit Sub
    End If


    For i = 1 To tmpstr
        letter = Mid$(Text1.Text, i, 1)
        encstr = Asc(letter) - pass$
        newstr = Chr$(encstr)
        decrypted$ = decrypted$ & newstr
    Next i
    Text1.Text = decrypted$
End Sub




Download this snippet    Add to My Saved Code

Encrypts text Comments

No comments have been posted about Encrypts text. Why not be the first to post a comment about Encrypts text.

Post your comment

Subject:
Message:
0/1000 characters