PHP 3DES encryption. NET cannot be resolved

Source: Internet
Author: User
Keywords NET PHP Encryption
netphp encryption

Because the project needs, need to interface with the other side, the other side is. NET developed, need to connect with our PHP, but after PHP 3DES encryption,. NET cannot be resolved, and the encrypted string with. NET encrypted string, the first half of the same, the second half is not the same! , that is, the string is not equal after the encryption, a master, high-score solution?
. NET programs:
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));

}

I wrote the level of PHP encryption:
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);//Convert to 16 binary

}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.