EasyManua.ls Logo

WAVECONTROL SMP2 - Page 90

WAVECONTROL SMP2
97 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Example c# code to generate the MD5
using System;
using System.text;
using System.Security.Cryptography;
private string AddMd5(string cmd)
{
String formatted_xml = cmd;
String result = string.Empty;
string[] string_parts;
/* Add a <md5>MD5_VALUE</md5> tag before the closing </cmd> tag. */
if (!formatted_xml.Contains(“<md5>”))
{
/* Split result: before “</cmd>” and after “</cmd>”: */
string[] tokenizer = new string[1];
tokenizer[0] = “</cmd>”;
string_parts = formatted_xml.Split(tokenizer, 3,
StringSplitOptions.None);
if (string_parts.Length == 2)
{
//Calculate MD5 of the chunk before “</cmd>
using (var md5 = MD5.Create())
{
string md5_str = BitConverter.ToString(md5.
ComputeHash(Encoding.UTF8.GetBytes(string_parts[0]))).Replace(“-”, “”).ToLower();
//Add it to the result
result = string_parts[0] + “<md5>” + md5_str + “</md5></
cmd>”;
}
}
}
return result;
}
User’s Manual Electromagnetic Field Meter SMP2 P. 88

Related product manuals