# @originjs/crypto-js-wasm
[English](README.md) | [中文](README-CN.md) --- `crypto-js-wasm` is a javascript library of crypto standards. Inspired by [crypto-js](https://github.com/brix/crypto-js), but now powered by [WebAssembly](https://webassembly.org/). - **Safe**: The process of encryption is fully **enclosed** and **invisible** thanks to WebAssembly - **Efficient**: Up to 16x **faster** than crypto-js (see [Benchmark](https://originjs.org/WASM-benchmark/#/)) - **Compatible**: Has the same API with crypto-js - **Browser & Nodejs**: Support both `browser` and `nodejs` - **Versatile**: **15+** crypto standards supported, including MD5, SHA-x, AES, RC4, etc - **ESM**: Written in ESM, build as UMD for compatibility ## What's new We have supported RSA and TypeScript now! ## Getting started ```bash npm install @originjs/crypto-js-wasm ``` or ```bash pnpm install @originjs/crypto-js-wasm ``` or ```bash yarn add @originjs/crypto-js-wasm ``` ## Usage Note that the async function `loadWasm()` should be called once (and once only!) for each algorithm that will be used, unless `loadAllWasm()` is called at the very beginning. ```javascript import CryptoJSW from '@originjs/crypto-js-wasm'; // (Optional) load all wasm files await CryptoJSW.loadAllWasm(); // Async/Await syntax await CryptoJSW.MD5.loadWasm(); const rstMD5 = CryptoJSW.MD5('message').toString(); console.log(rstMD5); // Promise syntax CryptoJSW.SHA256.loadWasm().then(() => { const rstSHA256 = CryptoJSW.SHA256('message').toString(); console.log(rstSHA256); }) ``` Please note that `HMAC` does not have a `loadWasm`, as a hasher must be specified if you want to use `HMAC` (i.e. `HmacSHA1`). And the `loadWasm` in `pbkdf2` only calls `SHA1.loadWasm` as `SHA1` is the default hasher of `pbkdf2`. If you specified another hasher, the corresponding `loadWasm` of the hasher should be called repectly. Same case in `evpkdf`/`MD5` as `MD5` is the default hasher of `evpkdf`. **Usage of RSA** Please refer to [this document](./docs/rsa.md). **Available standards** - MD5 / HmacMD5 - SHA1 / HmacSHA1 - SHA224 / HmacSHA224 - SHA256 / HmacSHA256 - SHA384 / HmacSHA384 - SHA512 / HmacSHA512 - SHA3 / HmacSHA3 - RIPEMD160 / HmacRIPEMD160 - PBKDF2 - EvpKDF