while trying pass hex value crypto cipher in node js getting blank return on ciphertext while proper return on ciphertext2. can't explain difference between 2 cases.
var secret = 'ymcnfa37drt+0p10pnspqsytwxlqncyu'; var cipher = crypto.createcipher('des3', secret); var plaintext = '3b9ac9ff'; var ciphertext = cipher.update(plaintext, 'hex', 'hex'); var ciphertext2 = cipher.update('3b9ac9ff', 'hex', 'hex'); console.log(plaintext + ' , ' +ciphertext + ' , '+ ciphertext2); gives me output
3b9ac9ff , , 0472620ba5ddf690
problem found. pointed @andreas.
var ciphertext = cipher.update(plaintext, 'hex', 'hex'); should
var ciphertext = cipher.update(plaintext, 'ascii', 'hex'); two reasons led confusion (although no justification being stupid) 1. node js doesn't give run time exception. instead behaves badly pointed out above. 2. output allowed hex leading me believe input allowed.
Comments
Post a Comment