Not a Member Yet,
Click here to Register
How do you like the new design?
It's cool, great job
[tally: 70%] 70%
It's okay
[tally: 20%] 20%
Its OK but I liked the old layout better
[tally: 0%] 0%
Please bring the old one back
[tally: 10%] 10%

votes: 10

ID: 5
Viewed: 3013
Added: Nov 21, 2001
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Easy String Encryption Using A Password There are many algorithms available for string encryption and decryption, but often they become complicated due to the need to ensure that the ASCII value of an encrypted character stays within the limits of a single byte (0-255). An elegant approach is to use the XOR function. The simple subroutine below will always give results falling within the 0-255 limit. It also has the advantage that a second call will reverse the encryption automatically. One thing you should be aware of is that the encrypted string may contain Chr$(0) values. While this will not be a problem with Visual Basic strings, other Windows objects treat Chr$(0) as an end-of-string character. Use of the encrypted string with a Text Box or in API calls may produce unexpected results.

Highlight all by clicking in box

Highlight All
Function Encrypt(sPassWord As String, sText As String) As String

Dim I As Integer
Dim iPChar As Integer
Dim iCChar As Integer

Do While Len(sPassWord) < Len(sText)

sPassWord = sPassWord & sPassWord


For I = 1 To Len(sText)

iPChar = Asc(Mid$(sPassWord, I, 1))

Char = Asc(Mid$(sText, I, 1))

d$(sText, I, 1) = Chr$(iPChar Xor iCChar)

Next I

Encrypt = sText

End Function;

No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 All Rights Reserved. Conditions