-
Notifications
You must be signed in to change notification settings - Fork 816
Open
Description
Hi,
I'm trying to use the AES_ECB decryption as mentionned in the doc.
the key is a string (the key is 256bit long) in a file and the encrypted data is also in an other file.
These were generated with openSsl.
forge keep throwing the same error which is
TypeError: tmp.length is not a function at forge.aes.Algorithm.initialize (path_to_app/node_modules/node-forge/lib/aes.js:203:19)
at new forge.cipher.BlockCipher (path_to_app/node_modules/node-forge/lib/cipher.js:118:18)
at Object.forge.cipher.createDecipher (path_to_app/node_modules/node-forge/lib/cipher.js:75:10)
at Object.<anonymous> (path_to_app/main.js:179:29)
and there's the code
const fs = require('fs')
const forge = require('node-forge')
let aes_key = fs.readFileSync(AES_KEY_PATH, 'utf8')
let encrypted = fs.readFileSync('test/a.encrypted.jpg', 'utf8')
let decipher = forge.cipher.createDecipher('AES-ECB', aes_key)
decipher.mode.unpad = false;
decipher.start(); //line 179, where the error is thrown
decipher.update(forge.util.createBuffer(encrypted));
decipher.finish();
let decrypted = decipher.output.getBytes();
fs.writeFileSync('test/a.decrypted.jpg', decrypted)
Could you tell me what i'm doing wrong ? Thanks
Metadata
Metadata
Assignees
Labels
No labels