andrew4582

MD5

Jan 29th, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Security.Cryptography;
  5.  
  6. public class MD5Helper
  7. {
  8.    public static string ToMD5(string Key, string Value)
  9.    {
  10.         byte[] bytes = Encoding.Default.GetBytes(Key);
  11.         byte[] buffer = Encoding.Default.GetBytes(Value);
  12.         byte[] buffer2 = new HMACMD5(bytes).ComputeHash(buffer);
  13.         //return Encoding.Default.GetString(buffer2);
  14.         StringBuilder bulider= new  StringBuilder(buffer2.Length);
  15.        
  16.         for (int i = 0; i <= buffer2.Length - 1; i++)
  17.         {
  18.             bulider.Append(buffer2[i].ToString("x"));
  19.         }
  20.        
  21.         return bulider.ToString();
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment