-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.questionIssues that look for answers.Issues that look for answers.wrong repoIssues that should be opened in another repository.Issues that should be opened in another repository.
Description
Version: v6.11.0
Platform: Linux econ-pc 4.4.0-79-generic #100~14.04.1-Ubuntu SMP Fri May 19 18:36:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Error
crypto.js:194
this._handle.initiv(cipher, toBuf(key), toBuf(iv));
^
Error: Invalid IV length
at Error (native)
at new Cipheriv (crypto.js:194:16)
at Object.Cipheriv (crypto.js:192:12)
at encrypt3DES (/home/mohanen/Desktop/myApp/index.js:47:29)
at Object.<anonymous> (/home/mohanen/Desktop/myApp/index.js:29:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
my code
function encrypt3DES (string){
let iv = Crypto.randomBytes(16);
let salt = "foobar";
let hash = Crypto.createHash("sha1");
hash.update(salt);
let key = hash.digest().slice(0, 16);
let encryption = Crypto.createCipheriv("des3", key, iv);
let cipher = encryption.update(string, "utf8", "base64");
cipher += cipher.final('base64');
console.log("[" + string + "] => [" + cipher + "]");
}
trying to write a simple function that encrypts a given string in 3DES-CBC
Metadata
Metadata
Assignees
Labels
cryptoIssues and PRs related to the crypto subsystem.Issues and PRs related to the crypto subsystem.questionIssues that look for answers.Issues that look for answers.wrong repoIssues that should be opened in another repository.Issues that should be opened in another repository.