In VB:
Imports System.Security.Cryptography
Public Function ComputeSHA1(ByVal textToHash As String) As String
Dim SHA1 As SHA1CryptoServiceProvider = New SHA1CryptoServiceProvider
Dim byteV As Byte() = System.Text.Encoding.UTF8.GetBytes(textToHash)
Dim byteH As Byte() = SHA1.ComputeHash(byteV)
SHA1.Clear()
Return Convert.ToBase64String(byteH)
End Function
In C#:
using System.Security.Cryptography;
public static String ComputeSHA1(string textToHash)
{
SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider();
byte[] byteV = System.Text.Encoding.UTF8.GetBytes(textToHash);
byte[] byteH = SHA1.ComputeHash(byteV);
SHA1.Clear();
return Convert.ToBase64String(byteH);
}
No comments:
Post a Comment