@@ -7,9 +7,8 @@ import type { Params } from './types';
|
||||
import scryptsy from 'scryptsy';
|
||||
|
||||
import { bufferToU8a, u8aToBuffer, u8aToU8a } from '@polkadot/util';
|
||||
import { scrypt } from '@polkadot/wasm-crypto';
|
||||
import { isReady, scrypt } from '@polkadot/wasm-crypto';
|
||||
|
||||
import { isWasmOnly } from '../helpers';
|
||||
import { randomAsU8a } from '../random/asU8a';
|
||||
import { DEFAULT_PARAMS } from './defaults';
|
||||
|
||||
@@ -22,7 +21,7 @@ interface Result {
|
||||
export function scryptEncode (passphrase?: HexString | Uint8Array | string, salt = randomAsU8a(), params = DEFAULT_PARAMS, onlyJs?: boolean): Result {
|
||||
const u8a = u8aToU8a(passphrase);
|
||||
|
||||
const password = isWasmOnly(onlyJs)
|
||||
const password = !onlyJs && isReady()
|
||||
? scrypt(u8a, salt, Math.log2(params.N), params.r, params.p)
|
||||
: bufferToU8a(
|
||||
scryptsy(u8aToBuffer(u8a), u8aToBuffer(salt), params.N, params.r, params.p, 64)
|
||||
|
||||
Reference in New Issue
Block a user