Hex code to byte array
--------------------------------------
public static byte[] DecodeHex(string hextext)
{
String[] arr = hextext.Split('-');
byte[] array = new byte[arr.Length];
for (int i = 0; i < arr.Length; i++)
array[i] = Convert.ToByte(arr[i], 16);
return array;
}
It guide you.
MD5 sample code for encrypt
-------------------------------------------
public static string Encrypt(string toEncrypt, bool useHashing, string imkey)
{
byte[] keyArray;
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
string key = imkey;
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}