Skip to main content

decrypt

Callable

  • decrypt(keystore: string | KeyStore, password: string | Uint8Array, nonStrict?: boolean): Promise<Web3Account>

  • Decrypts a v3 keystore JSON, and creates the account.


    Parameters

    • keystore: string | KeyStore

      the encrypted Keystore object or string to decrypt

    • password: string | Uint8Array

      The password that was used for encryption

    • optionalnonStrict: boolean

      if true and given a json string, the keystore will be parsed as lowercase.

    Returns Promise<Web3Account>

    Returns the decrypted Web3Account object Decrypting scrypt

    web3.eth.accounts.decrypt({
    version: 3,
    id: 'c0cb0a94-4702-4492-b6e6-eb2ac404344a',
    address: 'cda9a91875fc35c8ac1320e098e584495d66e47c',
    crypto: {
    ciphertext: 'cb3e13e3281ff3861a3f0257fad4c9a51b0eb046f9c7821825c46b210f040b8f',
    cipherparams: { iv: 'bfb43120ae00e9de110f8325143a2709' },
    cipher: 'aes-128-ctr',
    kdf: 'scrypt',
    kdfparams: {
    n: 8192,
    r: 8,
    p: 1,
    dklen: 32,
    salt: '210d0ec956787d865358ac45716e6dd42e68d48e346d795746509523aeb477dd'
    },
    mac: 'efbf6d3409f37c0084a79d5fdf9a6f5d97d11447517ef1ea8374f51e581b7efd'
    }
    }, '123').then(console.log);


    > {
    address: '0xcdA9A91875fc35c8Ac1320E098e584495d66e47c',
    privateKey: '67f476289210e3bef3c1c75e4de993ff0a00663df00def84e73aa7411eac18a6',
    signTransaction: [Function: signTransaction],
    sign: [Function: sign],
    encrypt: [AsyncFunction: encrypt]
    }