fix: unit tests
This commit is contained in:
@@ -2,7 +2,7 @@ import { createDecipheriv } from "crypto";
|
||||
import { CryptoResult } from ".";
|
||||
|
||||
const PREFIX = "encrypted_";
|
||||
const DEFAULT_IV = "twake_constantiv";
|
||||
// const DEFAULT_IV = Buffer.from("twake_constantiv", "utf-8");
|
||||
|
||||
export default {
|
||||
decrypt,
|
||||
@@ -25,9 +25,9 @@ function decrypt(data: string, encryptionKey: string): CryptoResult {
|
||||
const salt = encryptedArray[1]
|
||||
? Buffer.from(encryptedArray[1], "utf-8")
|
||||
: Buffer.from("", "utf-8");
|
||||
const iv = encryptedArray[2]
|
||||
const iv = encryptedArray.length >= 3
|
||||
? Buffer.from(encryptedArray[2], "base64")
|
||||
: Buffer.from(DEFAULT_IV, "utf-8");
|
||||
: Buffer.from("twake_constantiv", "utf-8");
|
||||
const password = Buffer.concat([Buffer.from(encryptionKey, "hex"), salt], 32);
|
||||
const decipher = createDecipheriv("AES-256-CBC", password, iv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user