| 08/26/2003
EncryptPasswordWinFormsVB2002-2003.zip
This tutorial
article with source code shows how to encrypt a password, save to a
disk file, and use it to authenticate a user.
You can encrypt a
password using the .NET Cryptography and Text namespaces.
Included in the free downloadable source
code is a class named EncryptPassword. This class contains a method
named 'EncryptString' that uses the Text namespace's UnicodeEncoding
method to convert a string passed into the class into a Byte array,
encrypts the string using the Cryptography namespace's
MD5CryptoServiceProvider and returns the encrypted string to the
caller.
In the Windows Forms example provided in
the source code are two methods.
The first, 'EncryptAndSave', takes a
password entered by a user, encrypts it with the EncryptPassword
class, then saves the encrypted password to file.
The second, 'ValidatePassword', takes a
password entered by a user, encrypts it with the EncryptPassword
class, retrieves a encrypted password from file, and validates that
the password provided by the user matches the password stored to
file.
Click the link above to download Visual
Basic source code in a Visual Studio solution which
demonstrates how to use the Cryptography and Text namespaces to
encrypt a password.
NOTE: The source code was created
with Visual Basic 2002. To use it with Visual Basic 2003, open it
with Visual Studio 2003 and just say yes when asked if you want to
convert it. |