mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 14:57:56 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { u8aConcat } from '@pezkuwi/util';
|
||||
import { naclEncrypt } from '../nacl/index.js';
|
||||
import { scryptEncode, scryptToU8a } from '../scrypt/index.js';
|
||||
import { jsonEncryptFormat } from './encryptFormat.js';
|
||||
export function jsonEncrypt(data, contentType, passphrase) {
|
||||
let isEncrypted = false;
|
||||
let encoded = data;
|
||||
if (passphrase) {
|
||||
const { params, password, salt } = scryptEncode(passphrase);
|
||||
const { encrypted, nonce } = naclEncrypt(encoded, password.subarray(0, 32));
|
||||
isEncrypted = true;
|
||||
encoded = u8aConcat(scryptToU8a(salt, params), nonce, encrypted);
|
||||
}
|
||||
return jsonEncryptFormat(encoded, contentType, isEncrypted);
|
||||
}
|
||||
Reference in New Issue
Block a user