How to encrypt with AES-256-CFB?

Viewed 32
const crypto = require('crypto');

var algorithm = 'AES-256-CFB';
var key = '1234567812345678';
var iv = '8765432187654321';
const plaintext = 'testing 123';

const cipher = crypto.createDecipheriv(algorithm, key, iv);
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
console.log(encrypted.toString('base64'));

How to encrypt a string using crypto algo AES-256-CFB ?

I'm getting this error in the line const cipher:

Uncaught RangeError RangeError: Invalid key length
    at createCipherBase (internal/crypto/cipher:116:19)
    at createCipherWithIV (internal/crypto/cipher:135:3)
    at Decipheriv (internal/crypto/cipher:289:3)
    at createDecipheriv (crypto:146:10)
    at <anonymous> (d:\test.js:8:23)
    at Module._compile (internal/modules/cjs/loader:1101:14)
    at Module._extensions..js (internal/modules/cjs/loader:1153:10)
    at Module.load (internal/modules/cjs/loader:981:32)
    at Module._load (internal/modules/cjs/loader:822:12)
    at executeUserEntryPoint (internal/modules/run_main:81:12)
    at <anonymous> (internal/main/run_main_module:17:47)

Invalid key length, what im missing?

0 Answers
Related