Skip to content

Instantly share code, notes, and snippets.

@lindexi
Created November 28, 2016 07:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lindexi/0ecf1d8de7a222cda5f058e74de335c1 to your computer and use it in GitHub Desktop.
Save lindexi/0ecf1d8de7a222cda5f058e74de335c1 to your computer and use it in GitHub Desktop.
public static string Md5(string str)
{
HashAlgorithmProvider hashAlgorithm =
HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5);
CryptographicHash cryptographic = hashAlgorithm.CreateHash();
IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf8);
cryptographic.Append(buffer);
return CryptographicBuffer.EncodeToHexString(cryptographic.GetValueAndReset());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment