1 | ;
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.naclEncrypt = void 0;
|
4 | const asU8a_js_1 = require("../random/asU8a.js");
|
5 | const tweetnacl_js_1 = require("./tweetnacl.js");
|
6 | /**
|
7 | * @name naclEncrypt
|
8 | * @summary Encrypts a message using the supplied secretKey and nonce
|
9 | * @description
|
10 | * Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated.
|
11 | * @example
|
12 | * <BR>
|
13 | *
|
14 | * ```javascript
|
15 | * import { naclEncrypt } from '@polkadot/util-crypto';
|
16 | *
|
17 | * naclEncrypt([...], [...]); // => [...]
|
18 | * ```
|
19 | */
|
20 | function naclEncrypt(message, secret, nonce = (0, asU8a_js_1.randomAsU8a)(24)) {
|
21 | return {
|
22 | encrypted: (0, tweetnacl_js_1.naclSecretbox)(message, nonce, secret),
|
23 | nonce
|
24 | };
|
25 | }
|
26 | exports.naclEncrypt = naclEncrypt;
|