我正在使用 NodeJS 编写 DES 加密代码。
根据DES算法,结果应该是这样的,
* http://www.unsw.adfa.edu.au/~lpb/src/DEScalc/DEScalc.html
An example DES test value, taken from
"H. Katzan, The Standard Data Encryption Algorithm, pp75-94, Petrocelli Books Inc., New York, 1977" is:
Key: 5B5A57676A56676E (HEX)
Plaintext: 675A69675E5A6B5A (HEX)
Ciphertext: 974AFFBF86022D1F (HEX)
但是,我的代码打印的值有些不同。
var assert = require("assert");
var crypto = require("crypto");
var plaintext = new Buffer( '675A69675E5A6B5A', 'hex' ).toString( 'binary' );
var key = new Buffer( '5B5A57676A56676E', 'hex' ).toString( 'binary' );
var cipher = crypto.createCipher( 'des-ecb', key );
var c = cipher.update( plaintext, 'binary', 'hex' );
c += cipher.final( 'hex' );
console.log( c );
我应该在上面的代码中修复什么?