@subsocial/utils
Version:
JavaScript utils for Subsocial blockchain.
26 lines (25 loc) • 802 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.naclDecrypt = void 0;
const tweetnacl_1 = __importDefault(require("tweetnacl"));
/**
* @name naclDecrypt
* @summary Decrypts a message using the supplied secretKey and nonce
* @description
* Returns an decrypted message, using the `secret` and `nonce`.
* @example
* <BR>
*
* ```javascript
* import { naclDecrypt } from '@subsocial/utils';
*
* naclDecrypt([...], [...], [...]); // => [...]
* ```
*/
function naclDecrypt(encrypted, nonce, secret) {
return tweetnacl_1.default.secretbox.open(encrypted, nonce, secret) || null;
}
exports.naclDecrypt = naclDecrypt;