Creating a simple class to encrypt strings
This code will help you to create class to encrypt strings
A simple namespace is created below for all your encryption requirements in the application
Imports System.Security.Cryptography
Imports System.Text
Imports System.Text.RegularExpressions
Namespace ASPNET.Handheld
Public Class Security
'*********************************************************************
'
' Security.Encrypt() Method
'
' The Encrypt method encryts a clean string into a hashed string
'
'*********************************************************************
Public Shared Function Encrypt(ByVal cleanString As String) As String
Dim clearBytes As [char]()
clearBytes = New UnicodeEncoding().GetBytes(cleanString)
Dim hashedBytes As [Byte]() = CType(CryptoConfig.CreateFromName("MD5"), HashAlgorithm).ComputeHash(clearBytes)
Dim hashedText As String = BitConverter.ToString(hashedBytes)
Return hashedText
End Function
End Class
End Namespace