Home  >  Article  >  Backend Development  >  php 3des加密.net无法解析

php 3des加密.net无法解析

WBOY
WBOYOriginal
2016-06-02 11:28:13757browse

netphp加密

因项目需要,需要与对方的接口对接 ,对方是.net开发的,需要与我们的php对接,但是php 3des加密后,.net的无法解析,且加密后的字符串与.net加密后的字符串,前半部分一样,后半部分就不一样!,也就是说加密后的字符串不相等,有高手吗,高分求解?
.net程序:
public static string Encrypt3DES(string a_strString, string a_strKey)

{

TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider();

DES.Key = ASCIIEncoding.ASCII.GetBytes(a_strKey);

DES.Mode = CipherMode.ECB;

ICryptoTransform DESEncrypt = DES.CreateEncryptor();

byte[] Buffer = ASCIIEncoding.ASCII.GetBytes(a_strString);

return Convert.ToBase64String(DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length));

}

我写的php加密程度:
function encrypt($string) {
$key = "05217c03d7b74fe581fc449b";
$cipher_alg = MCRYPT_TRIPLEDES;
$iv = mcrypt_create_iv(mcrypt_get_iv_size($cipher_alg,MCRYPT_MODE_ECB), MCRYPT_RAND);
$encrypted_string = mcrypt_encrypt($cipher_alg, $key, $string, MCRYPT_MODE_ECB, $iv);
return base64_encode($encrypted_string);//转化成16进制

<code>}</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn