15
根据字符串计算MD5哈希
我使用以下C#代码从字符串中计算MD5哈希值。它运作良好,并生成一个32个字符的十六进制字符串,如下所示: 900150983cd24fb0d6963f7d28e17f72 string sSourceData; byte[] tmpSource; byte[] tmpHash; sSourceData = "MySourceData"; //Create a byte array from source data. tmpSource = ASCIIEncoding.ASCII.GetBytes(sSourceData); tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource); // and then convert tmpHash to string... 有没有办法使用像这样的代码来生成16个字符的十六进制字符串(或12个字符的字符串)?32个字符的十六进制字符串很好,但是我认为客户输入代码会很无聊!