ethereum / js-ethereum-cryptography

Every cryptographic primitive needed to work on Ethereum, for the browser and Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert string to Uint8Array using sha256

acristoni opened this issue · comments

sha256, showed here in the documentation:

const hashn = toHex(sha256("string"));

is not working properly, because sha256 is not accepting string as type, only Uint8Array.

These is the log error message:
_assert.ts:10 Uncaught (in promise) TypeError: Expected Uint8Array
at Object.bytes (_assert.ts:10:41)
at utils.js:49:27
at transfer (Transfer.jsx:22:31)
at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
at Object.invokeGuardedCallbackDev (react-dom.d

and the code in the package from npm:
export declare const sha256: (msg: Uint8Array) => Uint8Array;