Package Exports
- ethereum-cryptography
- ethereum-cryptography/keccak.js
- ethereum-cryptography/pure/keccak.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ethereum-cryptography) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ethereum-cryptography
This npm package contains all the cryptographic primitives normally used when developing Javascript/TypeScript applications and tools for Ethereum.
This package contains pure-js implementations of these primitives:
keccak
Installation
Via npm
:
$ npm install ethereum-cryptography
Via yarn
:
$ yarn add ethereum-cryptography
Usage
There's a submodule available for each cryprographic primitive.
No index.js
is provided, as that would lead to huge bundles when using this
package for the web.
keccak
The keccack
submodule has four functions that receive a Buffer
with the
message to hash, and return a Buffer
with the hash. These are keccak224
,
keccak256
, keccak384
, and keccak512
.
Example usage
const { keccak256 } = require("ethereum-cryptography/keccak");
console.log(keccak256(Buffer.from("Hello, world!", "ascii")).toString("hex"));
Browser usage
This package works out of the box with all the major Javascript bundlers (e.g.
webpack
, Rollup
, Parcel
, Browserify
).
Opt-in native implementations (Node.js only)
If you are using this package in Node, you can install
ethereum-cryptography-native
to opt-in to use native implementations of some
of the cryptographic primitives provided by this package.
No extra work is needed for this to work. This package will detect that
ethereum-cryptography-native
is installed, and use it.
While installing ethereum-cryptography-native
will generally improve the
performance of your application, we recommend leaving the decision of installing
it to your users. It has multiple native dependencies that need to be compiled,
and this can be problematic in some environments.