Add to Google Add to My Yahoo!

Live Chat Here


Articles on ASP.NET

Thursday, July 19, 2007

DIGEST METHOD

Function GetDigest(tamperProofParams as String) as String
Dim Digest as String = String.Empty
Dim input as String = String.Concat(SecretSalt, tamperProofParams, SecretSalt)

'The array of bytes that will contain the encrypted value of input
Dim hashedDataBytes As Byte()

'The encoder class used to convert strPlainText to an array of bytes
Dim encoder As New System.Text.UTF8Encoding

'Create an instance of the MD5CryptoServiceProvider class
Dim md5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider

'Call ComputeHash, passing in the plain-text string as an array of bytes
'The return value is the encrypted value, as an array of bytes
hashedDataBytes = md5Hasher.ComputeHash(encoder.GetBytes(input))

'Base-64 Encode the results and strip off ending '==', if it exists
Digest = Convert.ToBase64String(hashedDataBytes).TrimEnd("=".ToCharArray())

Return Digest
End Function


--
Regards,
Munish Kalra

http://kalraonaspnet.blogspot.com
http://munishmca.co.nr

No comments: