mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 17:18:02 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.jsonEncrypt = jsonEncrypt;
|
||||
const util_1 = require("@pezkuwi/util");
|
||||
const index_js_1 = require("../nacl/index.js");
|
||||
const index_js_2 = require("../scrypt/index.js");
|
||||
const encryptFormat_js_1 = require("./encryptFormat.js");
|
||||
function jsonEncrypt(data, contentType, passphrase) {
|
||||
let isEncrypted = false;
|
||||
let encoded = data;
|
||||
if (passphrase) {
|
||||
const { params, password, salt } = (0, index_js_2.scryptEncode)(passphrase);
|
||||
const { encrypted, nonce } = (0, index_js_1.naclEncrypt)(encoded, password.subarray(0, 32));
|
||||
isEncrypted = true;
|
||||
encoded = (0, util_1.u8aConcat)((0, index_js_2.scryptToU8a)(salt, params), nonce, encrypted);
|
||||
}
|
||||
return (0, encryptFormat_js_1.jsonEncryptFormat)(encoded, contentType, isEncrypted);
|
||||
}
|
||||
Reference in New Issue
Block a user