AX2012 MD5加密

 1 static void TestMID5(Args _args)
 2 {
 3     ClrObject                           md5;
 4 
 5     System.Text.Encoding                encoding;
 6     ClrObject                           inputArray;
 7     ClrObject                           hashArray;
 8     int                                 i;
 9     ClrObject                           strBuilder;
10     str                                 input, result;
11     InterOpPermission                   perm = new InterOpPermission(INteropKind::ClrInterop);
12 
13     perm.assert();
14     input = "123456";
15     md5 = System.Security.Cryptography.MD5::Create();
16     encoding = System.Text.Encoding::get_UTF8(); // 根据需要选择
17     inputArray = encoding.GetBytes(input);
18     strBuilder = new System.Text.StringBuilder();
19     hashArray = md5.ComputeHash(inputArray);
20 
21     for(i = 0; i < 16; i++)
22     {
23         strBuilder.AppendFormat("{0:x2}",hashArray.GetValue(i));
24     }
25 
26     result = strBuilder.ToString();
27     CodeAccessPermission::revertAssert();
28     info(strFmt("%1", result));
29 }

 

posted @ 2020-07-31 17:06  一口一个小馒头  阅读(137)  评论(0编辑  收藏  举报