php 3des加密.net无法解析

WBOY
Release: 2016-06-02 11:28:13
Original
758 people have browsed it

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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!