crypto: change input var name in stream functions
This commit is contained in:
parent
97f4528e92
commit
fc39ac76b6
1 changed files with 4 additions and 4 deletions
|
@ -7,8 +7,8 @@ export function generateHmac(str, salt) {
|
||||||
return createHmac("sha256", salt).update(str).digest("base64url");
|
return createHmac("sha256", salt).update(str).digest("base64url");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encryptStream(str, iv, secret) {
|
export function encryptStream(plaintext, iv, secret) {
|
||||||
const buff = Buffer.from(JSON.stringify(str), "utf-8");
|
const buff = Buffer.from(JSON.stringify(plaintext), "utf-8");
|
||||||
|
|
||||||
const key = scryptSync(Buffer.from(secret, "base64url"), "salt", keyLength);
|
const key = scryptSync(Buffer.from(secret, "base64url"), "salt", keyLength);
|
||||||
const cipher = createCipheriv(algorithm, key, Buffer.from(iv, "base64url"));
|
const cipher = createCipheriv(algorithm, key, Buffer.from(iv, "base64url"));
|
||||||
|
@ -16,8 +16,8 @@ export function encryptStream(str, iv, secret) {
|
||||||
return Buffer.concat([ cipher.update(buff), cipher.final() ])
|
return Buffer.concat([ cipher.update(buff), cipher.final() ])
|
||||||
}
|
}
|
||||||
|
|
||||||
export function decryptStream(buf, iv, secret) {
|
export function decryptStream(ciphertext, iv, secret) {
|
||||||
const buff = Buffer.from(buf, "binary");
|
const buff = Buffer.from(ciphertext, "binary");
|
||||||
|
|
||||||
const key = scryptSync(Buffer.from(secret, "base64url"), "salt", keyLength);
|
const key = scryptSync(Buffer.from(secret, "base64url"), "salt", keyLength);
|
||||||
const decipher = createDecipheriv(algorithm, key, Buffer.from(iv, "base64url"));
|
const decipher = createDecipheriv(algorithm, key, Buffer.from(iv, "base64url"));
|
||||||
|
|
Loading…
Reference in a new issue