为什么OPENSSL在C++/PHP下AES加密解密结果不一致
2个回答
2016-06-18
展开全部
//////Aes解密//////源字符串///aes密钥,长度必须32位///解密后的字符串publicstaticstringDecryptAes(stringsource,stringkey){using(AesCryptoServiceProvideraesProvider=newAesCryptoServiceProvider()){aesProvider.Key=GetAesKey(key);aesProvider.Mode=CipherMode.ECB;aesProvider.Padding=PaddingMode.PKCS7;using(ICryptoTransformcryptoTransform=aesProvider.CreateDecryptor()){byte[]inputBuffers=Convert.FromBase64String(source);byte[]results=cryptoTransform.TransformFinalBlock(inputBuffers,0,inputBuffers.Length);aesProvider.Clear();returnEncoding.UTF8.GetString(results);}}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询