Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于以下PHP代码段的Node.js等效程序_Php_Node.js - Fatal编程技术网

用于以下PHP代码段的Node.js等效程序

用于以下PHP代码段的Node.js等效程序,php,node.js,Php,Node.js,有人能建议如何为下面的PHP代码段编写Node.js等效的加密模块程序吗 $source = ...; $secretKey = pack('H*', "SECRET_KEY"); $decoded = base64_decode($source); $decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $secretKey, $decoded, MCRYPT_MODE_ECB); 这个例子取自 这个例子取自 尝试使用此软件包:尝试使用此软件包:谢谢

有人能建议如何为下面的PHP代码段编写Node.js等效的加密模块程序吗

$source = ...;
$secretKey = pack('H*', "SECRET_KEY");
$decoded = base64_decode($source);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $secretKey, $decoded, MCRYPT_MODE_ECB);

这个例子取自


这个例子取自


尝试使用此软件包:尝试使用此软件包:谢谢Mike,但我得到了一个不同的npm模块,它工作了:-)。很好,不用担心:)var MCrypt=require('MCrypt')。MCrypt;var Aseecb=新MCrypt('rijndael-128','ecb');打开(新的缓冲区(密钥,'hex');var ciphertext=新缓冲区(输入'base64');var plaintext=aesEcb.decrypt(SOURCE.toString('utf8')//console.log(纯文本);谢谢,迈克,但我得到了一个不同的npm模块,它工作了:-)。很好,不用担心:)var MCrypt=require('MCrypt')。MCrypt;var Aseecb=新MCrypt('rijndael-128','ecb');打开(新的缓冲区(密钥,'hex');var ciphertext=新缓冲区(输入'base64');var plaintext=aesEcb.decrypt(SOURCE.toString('utf8')//console.log(纯文本);
// Import module
var rijndael = require('./examples/rijndael');

// Set key
var key = new Buffer('theonetruesecretkeytorulethemall', 'utf-8').toString('base64');
var iv = crypto.randomBytes(16).toString('base64');


// Encrypt message
var plaintext = 'hello, world!';
var ciphertext = rijndael.encrypt(plaintext, key, iv);

// 'hello, world!' encodes to
// '50yvJtooiLHUOAbniGgMHmZE18Op99Rhe+Y+G6AjPzM='


// Decrypt message
var decryptedMessage = rijndael.decrypt(ciphertext, key, iv);

// '50yvJtooiLHUOAbniGgMHmZE18Op99Rhe+Y+G6AjPzM=' decodes to
// 'hello, world!'