I need to perform MACing using the MD5 algorithm under the .Net Compact framework. I have got code in .Net for desktop version of application but that code is not working in .Net CF.
HMACMD5 myhmacMD5 = new HMACMD5(key);
HMACMD5 API is not working in .Net compact framwork. Is there any alternative way to perform the MACing in the .Net CF.
Loading

Sahil Jani196 reputationPosted Mar 25, 2011, 2:25 AM EDT
{
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.ComputeHash( dataToHash_Bytes );
Console.WriteLine( System.Text.Encoding.ASCII.GetString( result_Bytes ));
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] md5_Bytes = md5.ComputeHash( dataToHash_Bytes);
Console.WriteLine( System.Text.Encoding.ASCII.GetString( md5_Bytes ) );
}
}
You can use this one. For this you have to import System.Security.Cryptography.
If this code will help you then mark it as a correct answer.
Gaurav Sharma19 reputationPosted Mar 29, 2011, 11:06 PM EDT
Sompal AryaRank #3,964 · 375 reputationPosted Jun 3, 2015, 3:12 AM EDT