C_Sharp/Hash Edit Diff Refresh Backlink Random Search History Help Setting Hide Show static string hex_md5(string input) { // Create a new instance of the MD5CryptoServiceProvider object. System.Security.Cryptography.MD5 md5Hasher = System.Security.Cryptography.MD5.Create(); // Convert the input string to a byte array and compute the hash. byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input)); // Create a new Stringbuilder to collect the bytes // and create a string. StringBuilder sBuilder = new StringBuilder(); // Loop through each byte of the hashed data // and format each one as a hexadecimal string. for (int i = 0; i < data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); // x2- Lower case, X2- Upper case } // Return the hexadecimal string. return sBuilder.ToString(); } ... Console.WriteLine(hex_md5("1")); c4ca4238a0b923820dcc509a6f75849b 이 글에는 0 개의 댓글이 있습니다. Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus