
ARCHIVE: TIPS & TRICKS
Encryption made simple
Kris McCann 02.27.2001
Rating: -3.58- (out of 5)




Encryption made simple
Kris McCann
If you've ever written an application that stores passwords, you'll know the
importance of encryption. There's no point in password protecting things if all
a user has to do is open a file or database to get all of the stored passwords.
It is possible, however, to write a very simple function that will both encrypt
and decrypt passwords. Simply pass the function the string you wish to encrypt,
and a short key (to make it harder to break your encryption), and it will return
the encrypted version. Pass it the encrypted version, and it will translate it
back into plain text. Enjoy.
Private Function Encrypt(ByVal strInput As String, ByVal strKey As String) As
String
Dim iCount As Long
Dim lngPtr As Long
For iCount = 1 To Len(strInput)
Mid(strInput, iCount, 1) = Chr((Asc(Mid(strInput, iCount, 1))) Xor
(Asc(Mid(strKey, lngPtr + 1, 1))))
lngPtr = ((lngPtr + 1) Mod Len(strKey))
Next iCount
Encrypt = strInput
End Function
------------------------------------------------------
Thanks, Kris. For your interest in SearchVB we'll be sending you a
SearchVB denim shirt.
Kris McCann is a Senior Programmer/Designer for Europa Systems Ltd,
located in Vancouver, BC, Canada.
 |

|
|
 |
|
 |