UNPKG

560 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { assert, hexToU8a, isHex } from '@polkadot/util';
4import { base64Decode } from "../base64/index.js";
5import { jsonDecryptData } from "./decryptData.js";
6export function jsonDecrypt({
7 encoded,
8 encoding
9}, passphrase) {
10 assert(encoded, 'No encrypted data available to decode');
11 return jsonDecryptData(isHex(encoded) ? hexToU8a(encoded) : base64Decode(encoded), passphrase, Array.isArray(encoding.type) ? encoding.type : [encoding.type]);
12}
\No newline at end of file