
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@originjs/crypto-js-wasm
Advanced tools
An alternate to crypto-js implemented with WebAssembly and ESM
crypto-js-wasm
is a javascript library of crypto standards. Inspired by crypto-js, but now powered by WebAssembly.
browser
and nodejs
npm install @originjs/crypto-js-wasm
or
pnpm install @originjs/crypto-js-wasm
or
yarn add @originjs/crypto-js-wasm
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.
import CryptoJSW from '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);
})
Available standards
Coming next
The benchmark below is run on a desktop PC (i5-4590, 16 GB RAM, Windows 10 Version 21H2 (OSBuild 19044, 1466)).
Chrome 102.0.5005.63:
Firefox 101.0:
Nodejs v16.6.4:
# install dependencies
pnpm install
# build for production
pnpm run build
# run all tests
pnpm run test
# run all tests with coverage
pnpm run coverage
This is because the WebAssembly binary needs to be load by WebAssembly.instantiate
, and it is async.
The async WebAssembly.instantiate
is recommended instead of its sync variant WebAssembly.instance
, and in many cases the WebAssembly.instance
can not load WebAssembly binary whose size is not small enough.
This is because crypto-js-wasm
may be used in browser
or nodejs
. This is relative elegant implementation comparing with wasm loader
in browser
(powered by webpack, vite or something else) or fs
in nodejs
.
Distributed under the Mulan Permissive Software License
FAQs
An alternative to crypto-js implemented with WebAssembly and ESM
The npm package @originjs/crypto-js-wasm receives a total of 296 weekly downloads. As such, @originjs/crypto-js-wasm popularity was classified as not popular.
We found that @originjs/crypto-js-wasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.