问题描述
publicstaticstringEncrypt3DES(stringa_strString,stringa_strKey){TripleDESCryptoServiceProviderDES=newTripleDESCryptoServiceProvider();DES.Key=ASCIIEncoding.ASCII.GetBytes(a_strKey);DES.Mode=CipherMode.ECB;ICryptoTransformDESEncrypt=DES.CreateEncryptor();byte[]Buffer=ASCIIEncoding.ASCII.GetBytes(a_strString);byte[]Buffer2=DESEncrypt.TransformFinalBlock(Buffer,0,Buffer.Length);StringBuilderbuilder=newStringBuilder(Buffer2.Length*3);foreach(bytenuminBuffer2){builder.Append(Convert.ToString(num,16).PadLeft(2,'0').PadRight(3,''));}returnbuilder.ToString().ToUpper().Replace("","");}
这是我的C#代码我用C#的源码测试的结果:KEY:123456789012345678901234明文:1054DASF8ASD4GAS5D1G3A2SD密文:151217178983A3509F5FD3AB94857A633BA927CE8A5414D1DC29BE05CC94DD5F然后标准的工具是:KEY:123456789012345678901234明文:1054DASF8ASD4GAS5D1G3A2SD密文:151217178983A3509F5FD3AB94857A633BA927CE8A5414D1AB1359AAD7819BC6最后面8组数据是不一样的,我工具用的是3DES的EDE3模式,求教了,谢谢
解决方案
解决方案二:
DES.Key=ASCIIEncoding.ASCII.GetBytes(a_strKey);DES.Mode=CipherMode.ECB;这两个可能有其中一个或两个都和那个‘标准工具’不同