mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 06:47:57 +00:00
14 lines
507 B
JavaScript
14 lines
507 B
JavaScript
import { hexToU8a, isHex } from '@pezkuwi/util';
|
|
import { base64Decode } from '../base64/index.js';
|
|
import { jsonDecryptData } from './decryptData.js';
|
|
export function jsonDecrypt({ encoded, encoding }, passphrase) {
|
|
if (!encoded) {
|
|
throw new Error('No encrypted data available to decode');
|
|
}
|
|
return jsonDecryptData(isHex(encoded)
|
|
? hexToU8a(encoded)
|
|
: base64Decode(encoded), passphrase, Array.isArray(encoding.type)
|
|
? encoding.type
|
|
: [encoding.type]);
|
|
}
|