Special characters in encryption key - different output
TheTrunk opened this issue · comments
Tadeas Kmenta commented
Using special language native characters in encryption key result in different crypted phrase compared to native crypto node module.
Example of characters: ěščřžýáíéśćżź and way more.
Reproduction code:
const crypto = require("crypto");
const cryptoBrowser = require("crypto-browserify");
const algorithm = "aes-256-ctr";
const encryptionkey = "asdasdasdsadś gqwfwqrn";
const encrypt = crypto.createCipher(algorithm, encryptionkey);
let crypted = encrypt.update("123456781234565", "utf8", "hex");
crypted += encrypt.final("hex");
console.log(crypted); // 49a45f088f2c47cc91d62ac5290eaa
const encryptB = cryptoBrowser.createCipher(algorithm, encryptionkey);
let cryptedB = encryptB.update("123456781234565", "utf8", "hex");
cryptedB += encryptB.final("hex");
console.log(cryptedB); // 97a55dbe16a6fad4930e8122a0b554
Thank you for explanation and more insight into why it is happening and how to resolve it in case I want to have these special characters in encryption key.