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));
}


Support The Author

 If you found value in what I share, I've set up a Buy Me a Coffee page as a way to show your support.

Buy Me a Coffee

Post a Comment


All Comments


No comments. Be the first one to comment on this post.

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 "buy me a coffee" link.
Join us.

Blog Tags