AESencryption不同于节点和PHP
我有两个脚本,都使用相同的algorithm来encryption具有相同的密钥和IV的string。 但结果是不同的。 openssl_encrypt仍然使用不同的填充scheme比节点还是我错过了别的嘻嘻?
节点
const crypto = require('crypto'); var passphrase = '29486a7a37664140'; var iv = '76e69938cdf5bb64'; var text = '1234567890123456'; var cipher = crypto.createCipheriv('aes-128-ctr', passphrase, iv) var crypted = cipher.update(text,'utf8','hex') crypted += cipher.final('hex'); var result = crypted + ':' + iv; console.log('crypted: (' + crypted.length + ' chars)', crypted); // crypted: (32 chars) b94107e56900ec8270a847bbf457eaa6
PHP
<?php $encrypt_method = "AES-128-CTR"; $passphrase = '29486a7a37664140'; $iv = '76e69938cdf5bb64'; $text = '1234567890123456'; $encrypted = openssl_encrypt( $text, $encrypt_method, $passphrase, 0, $iv ); echo 'crypted (' . strlen($encrypted) . ' chars): ' . $encrypted; // crypted (24 chars): uUEH5WkA7IJwqEe79Ffqpg== ?>
好吧,呃…蠢 编码问题:
改变我的节点部分使用bas64作品
var cipher = crypto.createCipheriv('aes-128-ctr', passphrase, iv) var crypted = cipher.update(text,'utf8','base64') crypted += cipher.final('base64');
- Node.js / SAML:如何解密RequestedSecurityToken的内容
- 在java中encryption,在node.js中解密
- 节点密码和encryption-jsencryption和解密之间的兼容性
- MongoDB和NodeJS中的敏感数据分离 – 通过encryption密钥引用
- 如何在Python中encryption和在Javascript中解密?
- Node.js Crypto类使用更新的版本返回不同的结果
- RSA Javaencryption和Node.js解密不起作用
- 使用node.js请求让我们encryption“无法validation第一个证书”的错误
- Bash脚本和Javascript的标准哈希algorithm?