Dez 18 2008

C#: Den MD5 Hash eines Strings als String

Tag: .NETMichael @ 18:42
public string getMD5Hash(string strSource)
{
String strResult;

if ((strSource == null) || (strSource.Length == 0))
{
strResult = string.Empty;
}
else
{

System.Security.Cryptography.MD5CryptoServiceProvider objMD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] arrTextToHash = Encoding.Default.GetBytes(strSource);
byte[] arrResult = objMD5.ComputeHash(arrTextToHash);

strResult =  System.BitConverter.ToString(arrResult);
}

return strResult;
}