MD5 hashing

MD5 hashing + transformation to HEX format for the value to be JSON/XML compatible.
str signature   = 'some string';
//System.Byte[]       byteArray   = System.Text.Encoding::get_UTF8().GetBytes(signature);
System.Byte[]       byteArray   = System.Text.Encoding::get_ASCII().GetBytes(signature);
System.Byte[]       byteArray2;
//System.IO.MemoryStream  stream      = new System.IO.MemoryStream(byteArray);
//Info(strFmt('Signature: %1', signature));
str                 signatureMd5 = '';

System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5::Create();
//byteArray2 = md5.ComputeHash(stream);
byteArray2 = md5.ComputeHash(byteArray);
// signatureMd5 = System.Text.Encoding::get_UTF8().GetString(byteArray2);
// signatureMd5 = System.Text.Encoding::get_ASCII().GetString(byteArray2);
// to HEX
for (int a = 0; a < byteArray2.Length; a++)
{
     signatureMd5 += System.String::Format('{0:x2}', byteArray2.Get(a));
}


 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units.
Join us.

Blog Tags