npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@miracl/crypto-js

v4.0.0

Published

Crypto Library in JavaScript

Readme

MIRACL Crypto JS Library

Description

MCJS - MIRACL Crypto JavaScript

  • MCJS is a standards compliant JavaScript cryptographic library with no external dependencies except for the random seed source.

  • MCJS supports the standards for RSA, ECDH, ECIES, ECDSA and M-PIN, AES-GCM encryption/decryption, SHA256, SHA384, SHA512 and SHA3 hash functions and a cryptographically secure random number generator. Furthermore we recently added New Hope, a post-quantum key exchange.

  • MCJS is Node.js compatible and browser compatible (see some examples below).

Install and run tests

Node.js (minimum v6.9.5) and npm are required in order to build the library and run the tests. Install also the node.js modules required with the command

npm install

Run all the tests with the following command

npm test

Quick Start

Elliptic Curves

Suppose you want to implement ECDH with NIST256 elliptic curve. First you need to initialize the context:

import CTX from "@miracl/crypto-js";

var ctx = new CTX("NIST256");

then you can call the functions as follows:

ctx.ECDH.KEY_PAIR_GENERATE(...);
ctx.ECDH.ECPSVDP_DH(...);

If you need to use more than one elliptic curve in the same script you only need to initialize two different contexts, for example

var ctx1 = new CTX("NIST256");
var ctx2 = new CTX("C25519");

The following is the list of all elliptic curves supported by MCJS

[
    "ED25519",
    "C25519",
    "SECP256K1",
    "NIST256",
    "NIST384",
    "BRAINPOOL",
    "ANSSI",
    "HIFIVE",
    "GOLDILOCKS",
    "C41417",
    "NIST521",
    "NUMS256W",
    "NUMS256E",
    "NUMS384W",
    "NUMS384E",
    "NUMS512W",
    "NUMS512E",
    "FP256BN",
    "FP512BN",
    "BN254",
    "BN254CX",
    "BLS383",
    "BLS24",
    "BLS48",
    "BLS381",
    "BLS461"
];

RSA

This library supports also RSA encryption/decryption and RSA signature. The following is a quick example on how to use RSA. First initialize the context

import CTX from "@miracl/crypto-js";

var ctx = new CTX("RSA2048");

then you can call the RSA functions as follows:

ctx.RSA.ENCRYPT(...);
ctx.RSA.DECRYPT(...);

The following is the list of all the RSA security level supported by MCJS

['RSA2048','RSA3072','RSA4096'];

Other functions

MCJS supports SHA256, SHA384, SHA512, AES-GCM encryption and Marsaglia & Zaman random number generator. Those functions are contained in every context initialized with RSA or with an elliptic curve. If you want to create a context supporting only those general functions then initialize it with no parameter as follows:

import CTX from "@miracl/crypto-js";

var ctx = new CTX();

Run examples

Node.js examples are provided - please see ./examples/node. Use the following command to run an example

node ./examples/node/example_ECC_NIST256.js

Browsers

The library source code is browser compatible. The browser examples are locates in ./examples/browser.