node.js-php and Nodejs Encrypted data interoperability

Source: Internet
Author: User
An example of the cryptographic decryption code for NODEJS is as follows:

#!/usr/bin/env node var crypto = require (' crypto '); Decryption function decode (Cryptkey, IV, Secretdata) {var decipher = Crypto.createdecipheriv (' AES-256-CBC ', C                Ryptkey, iv), decoded = Decipher.update (Secretdata, ' base64 ', ' UTF8 ');        decoded + = decipher.final (' UTF8 ');    return decoded;  }//Decrypt function encode (Cryptkey, IV, ClearData) {var encipher = Crypto.createcipheriv (' AES-256-CBC ',        Cryptkey, iv), encoded = Encipher.update (cleardata, ' utf8 ', ' base64 ');        encoded + = encipher.final (' base64 ');    return encoded; } var Cryptkey = Crypto.createhash (' sha256 '). Update (' __tazai_wolf__key '). Digest (), iv = ' 1234567890000    BUF = "Hello World", enc = Encode (Cryptkey, IV, BUF);    var dec = decode (Cryptkey, IV, ENC);        function B64enc (data) {var b = new Buffer (data, ' binary ');    Return b.tostring (' base64 '); }console.warn ("Encoded LengTh: ", enc); Console.warn (" Decoded All: "+ dec); 

How can PHP write the corresponding encryption and decryption code?
Required to be able to solve the above encryption, such as: gpkr1wgbfhmvnd/hr0eabg==
You can also encrypt the data to decrypt the Nodejs.

Reply content:

An example of the cryptographic decryption code for NODEJS is as follows:

#!/usr/bin/env node var crypto = require (' crypto '); Decryption function decode (Cryptkey, IV, Secretdata) {var decipher = Crypto.createdecipheriv (' AES-256-CBC ', C                Ryptkey, iv), decoded = Decipher.update (Secretdata, ' base64 ', ' UTF8 ');        decoded + = decipher.final (' UTF8 ');    return decoded;  }//Decrypt function encode (Cryptkey, IV, ClearData) {var encipher = Crypto.createcipheriv (' AES-256-CBC ',        Cryptkey, iv), encoded = Encipher.update (cleardata, ' utf8 ', ' base64 ');        encoded + = encipher.final (' base64 ');    return encoded; } var Cryptkey = Crypto.createhash (' sha256 '). Update (' __tazai_wolf__key '). Digest (), iv = ' 1234567890000    BUF = "Hello World", enc = Encode (Cryptkey, IV, BUF);    var dec = decode (Cryptkey, IV, ENC);        function B64enc (data) {var b = new Buffer (data, ' binary ');    Return b.tostring (' base64 '); }console.warn ("Encoded LengTh: ", enc); Console.warn (" Decoded All: "+ dec); 

How can PHP write the corresponding encryption and decryption code?
Required to be able to solve the above encryption, such as: gpkr1wgbfhmvnd/hr0eabg==
You can also encrypt the data to decrypt the Nodejs.

  • 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.