ly
Explore posts from serversbad resource id with node:crypto
function test() {
const key = randomBytes(32);
const iv = randomBytes(16);
const cipher = createCipheriv("aes-256-cbc", key, iv);
const decipher = createDecipheriv("aes-256-cbc", key, iv);
const data = "Hello World";
const encrypted =
cipher.update(data, "utf8", "base64") + cipher.final("base64");
const decrypted =
decipher.update(encrypted, "base64", "utf8") + decipher.final("utf8");
console.dir({ data, encrypted, decrypted });
}
test();
function test() {
const key = randomBytes(32);
const iv = randomBytes(16);
const cipher = createCipheriv("aes-256-cbc", key, iv);
const decipher = createDecipheriv("aes-256-cbc", key, iv);
const data = "Hello World";
const encrypted =
cipher.update(data, "utf8", "base64") + cipher.final("base64");
const decrypted =
decipher.update(encrypted, "base64", "utf8") + decipher.final("utf8");
console.dir({ data, encrypted, decrypted });
}
test();
error: Uncaught BadResource: Bad resource ID
cipher.update(data, "utf8", "base64") + cipher.final("base64");
^
at Cipheriv.final (ext:deno_node/internal/crypto/cipher.ts:35:13)
error: Uncaught BadResource: Bad resource ID
cipher.update(data, "utf8", "base64") + cipher.final("base64");
^
at Cipheriv.final (ext:deno_node/internal/crypto/cipher.ts:35:13)
10 replies