Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```csharp
- private static string GetHash(string text)
- {
- MD5 MD5 = new MD5CryptoServiceProvider();
- byte[] asciiBytes = Encoding.ASCII.GetBytes(text);
- return GetHexString(MD5.ComputeHash(asciiBytes));
- }
- private static string GetHexString(byte[] bytes)
- {
- string text = string.Empty;
- for (int i = 0; i < bytes.Length; i++)
- {
- byte b = bytes[i];
- int n, n1, n2;
- n = b;
- n1 = n & 15;
- n2 = (n >> 4) & 15;
- if (n2 > 9)
- {
- text += ((char) (n2 - 10 + (int) 'A')).ToString();
- }
- else
- {
- text += n2.ToString();
- }
- if (n1 > 9)
- {
- text += ((char) (n1 - 10 + (int) 'A')).ToString();
- }
- else
- {
- text += n1.ToString();
- }
- if ((i + 1) != bytes.Length && (i + 1) % 2 == 0)
- {
- text += "-";
- }
- }
- return text;
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement