Csharp/CSharp Tutorial/Security/MD5
Produce an MD5 hash
<source lang="csharp">using System; using System.Security.Cryptography;
class Class1 { static void Main(string[] args) { string dataToHash = "this is a test"; string key = "ABCDEFGHIJKLMNOPQRSTUVWX"; byte[] dataToHash_Bytes = System.Text.Encoding.Unicode.GetBytes( dataToHash ); byte[] key_Bytes = System.Text.Encoding.ASCII.GetBytes( key ); MACTripleDES mac = new MACTripleDES( key_Bytes ); byte[] result_Bytes = mac.ruputeHash( dataToHash_Bytes ); Console.WriteLine( System.Text.Encoding.ASCII.GetString( result_Bytes ));
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); byte[] md5_Bytes = md5.ruputeHash( dataToHash_Bytes); Console.WriteLine( System.Text.Encoding.ASCII.GetString( md5_Bytes ) ); } }</source>