加密: 调用时: Encrypt_DES16(“2AF349243535BCD3”, "1111111111111111");
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);