Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
ASP.NET: Encrypt a string using MD5
From Wiki
Summary: Encrypt a string using MD5 encryption
Pass a string to the function and look at the returned string which is MD5 encrypted.
- Public Function MD5Encrypt(ByVal EncString As String) As String
- 'Variable Declarations
- Dim MD5String As String
- Dim EncStringBytes() As Byte
- Dim Encoder As New UTF8Encoding
- Dim MD5Hasher As New MD5CryptoServiceProvider
- 'Converts the String to bytes
- EncStringBytes = Encoder.GetBytes(EncString)
- 'Generates the MD5 Byte Array
- EncStringBytes = MD5Hasher.ComputeHash(EncStringBytes)
- 'Create MD5 hash
- MD5String = BitConverter.ToString(EncStringBytes)
- MD5String = MD5String.Replace("-", "")
- 'Returns the MD5 encrypted string to the calling object
- Return MD5String
- End Function
This Hack is part of the ASP.NET Hacks collection



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.