/// 加密原函数
/// </summary>
/// 加密原串</param>
/// 密钥</param>
///
public static string Encrypt_DES16(string str_in_data, string str_DES_KEY)
{
try
{
byte[] shuju = new byte[8];
byte[] keys = new byte[8];
for (int i = 0; i < 8; i++)
{
shuju[i] = Convert.ToByte(str_in_data.Substring(i * 2, 2), 16);
keys[i] = Convert.ToByte(str_DES_KEY.Substring(i * 2, 2), 16);
}
DES desEncrypt = new DESCryptoServiceProvider();
desEncrypt.Mode = CipherMode.ECB;
//desEncrypt.Key = ASCIIEncoding.ASCII.GetBytes(str_DES_KEY);
desEncrypt.Key = keys;
byte[] Buffer;
Buffer = shuju;//ASCIIEncoding.ASCII.GetBytes(str_in_data);
ICryptoTransform transForm = desEncrypt.CreateEncryptor();
byte[] R;
R = transForm.TransformFinalBlock(Buffer, 0, Buffer.Length);
string return_str = "";
foreach (byte b in R)
{
return_str += b.ToString("X2");
}
return_str = return_str.Substring(0, 16);
return return_str;
}
catch (Exception e)
{
throw e;
}
}