The following is an example of the Code for encryption and decryption in nodejs: {code...} How can php write the corresponding encryption and decryption code? It is required that the encrypted data such as Gpkr1WGBFhMvNdHr0eaBg can also be decrypted to nodejs. The following is an example of the Code for encryption and decryption of nodejs:
#! /Usr/bin/env node var crypto = require ('crypto'); // decrypt function decode (cryptkey, iv, secretdata) {var decipher = crypto. createDecipheriv ('aes-256-cbc', cryptkey, 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 = '000000', 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 I write the corresponding encryption and decryption code in php?
The above encrypted data, such as Gpkr1WGBFhMvNd/Hr0eaBg =
Data can also be encrypted to nodejs for decryption.
Reply content:
The following is an example of the Code for encryption and decryption of nodejs:
#! /Usr/bin/env node var crypto = require ('crypto'); // decrypt function decode (cryptkey, iv, secretdata) {var decipher = crypto. createDecipheriv ('aes-256-cbc', cryptkey, 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 = '000000', 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 I write the corresponding encryption and decryption code in php?
The above encrypted data, such as Gpkr1WGBFhMvNd/Hr0eaBg =
Data can also be encrypted to nodejs for decryption.