MetroStyleアプリを作成していて、文字列のMD5コードを生成したいと思います。これまで私はこれを使用しました:
public static string ComputeMD5(string str)
{
try
{
var alg = HashAlgorithmProvider.OpenAlgorithm("MD5");
IBuffer buff = CryptographicBuffer.ConvertStringToBinary(str, BinaryStringEncoding.Utf8);
var hashed = alg.HashData(buff);
var res = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, hashed);
return res;
}
catch (Exception ex)
{
return null;
}
}
System.ArgumentOutOfRangeException
ただし、次のエラーメッセージが表示されたタイプの例外がスローされます。
No mapping for the Unicode character exists in the target multi-byte code page. (Exception from HRESULT: 0x80070459)
私はここで何が間違っているのですか?