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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sebastienrousseau/crypto-lib

v0.0.3

Published

Crypto Lib is a powerful intuitive cryptographic JavaScript library that encapsulates common algorithms, functions and provides an interface for low-level cryptographic operations.

Downloads

25

Readme

⚙️ Crypto Lib

Banner representing Crypto Lib

NPM Version Coverage Status Maintained with Lerna License Made with Love

WebsiteDocumentationSubmit an IssueContributing Guidelines


👋 Welcome to Crypto Lib

Crypto Lib is a powerful intuitive cryptographic JavaScript library that encapsulates common algorithms, functions and provides an interface for low-level cryptographic operations.

divider

✨ Key Features

The cryptographic operations include:

  • Authentication via Digital Signature,
  • Confidentiality via Encryption and Decryption,
  • Compression,
  • Key Generation,
  • Key Management,
  • Pseudorandom Number Generation,
  • Signature Verification.

This library is based on OpenPGP.js - a JavaScript implementation of the OpenPGP protocol. It implements RFC4880 and parts of RFC4880bis.

Development of this library is hosted by GitHub at the following page. Source code is available to everyone under the standard MIT license.

divider

⏩ Getting Started

👉 Note: » Crypto Lib is a Node.js module available through the npm registry. Before installing, download and install Node.js. Node.js 12.20.0 or higher is required.

This allows you to always be on the latest version when we release new builds with automatic upgrades.

divider

🔧 Installation

1️⃣ Install the Crypto Library via npm, yarn or pnpm package managers:

  • npm i @sebastienrousseau/crypto-lib
  • yarn add @sebastienrousseau/crypto-lib
  • pnpm add @sebastienrousseau/crypto-lib

For users who are unable to install the Crypto Lib, released builds can be manually downloaded from this repository's Releases page.

What's included

Within the download you'll find all the crypto lib source files grouped into the dist folder.

You'll see something like this:

.
├── COPYRIGHT
├── Makefile
├── Report.txt
├── bin
│   ├── crypto-lib.d.ts
│   ├── crypto-lib.d.ts.map
│   ├── crypto-lib.js
│   ├── crypto-lib.js.map
│   ├── cryptolib.d.ts
│   ├── cryptolib.d.ts.map
│   ├── cryptolib.js
│   └── cryptolib.js.map
├── config
│   ├── config.d.ts
│   ├── config.d.ts.map
│   ├── config.js
│   └── config.js.map
├── enums.d.ts
├── enums.d.ts.map
├── enums.js
├── enums.js.map
├── index.d.ts
├── index.d.ts.map
├── index.js
├── index.js.map
├── key
│   ├── key.d.ts
│   ├── key.d.ts.map
│   ├── key.js
│   └── key.js.map
├── lib
│   ├── decrypt.d.ts
│   ├── decrypt.d.ts.map
│   ├── decrypt.js
│   ├── decrypt.js.map
│   ├── encrypt.d.ts
│   ├── encrypt.d.ts.map
│   ├── encrypt.js
│   ├── encrypt.js.map
│   ├── generate.d.ts
│   ├── generate.d.ts.map
│   ├── generate.js
│   ├── generate.js.map
│   ├── generateSessionKey.d.ts
│   ├── generateSessionKey.d.ts.map
│   ├── generateSessionKey.js
│   ├── generateSessionKey.js.map
│   ├── index.d.ts
│   ├── index.d.ts.map
│   ├── index.js
│   ├── index.js.map
│   ├── reformat.d.ts
│   ├── reformat.d.ts.map
│   ├── reformat.js
│   ├── reformat.js.map
│   ├── revoke.d.ts
│   ├── revoke.d.ts.map
│   ├── revoke.js
│   ├── revoke.js.map
│   ├── session.d.ts
│   ├── session.d.ts.map
│   ├── session.js
│   ├── session.js.map
│   ├── sign.d.ts
│   ├── sign.d.ts.map
│   ├── sign.js
│   ├── sign.js.map
│   ├── verify.d.ts
│   ├── verify.d.ts.map
│   ├── verify.js
│   └── verify.js.map
├── package.json
└── types
    ├── types.d.ts
    ├── types.d.ts.map
    ├── types.js
    └── types.js.map

5 directories, 72 files

2️⃣ Set up your app

You can get started with a simple app by running the following in your terminal:

> mkdir my-app
> cd my-app
> yarn add @sebastienrousseau/crypto-lib -D # or yarn or pnpm
> yarn start \
--name "Jane Doe" \
--email "[email protected]" \
--passphrase "123456789abcdef" \
--type "rsa" \
--curve "" \
--bits 2048 \
--expiration 0 \
--format armored \

3️⃣ Try it out and let us know what you think!

divider

❯ Crypto Lib commands

The Crypto Lib accepts multiple types of options. Options are a list of flags and other parameters that can control the behavior of the Crypto Lib as a whole.

Below is the full list of supported options for the Crypto Lib.

Generating a new RSA key pair

RSA is a public-key algorithm for encrypting and signing messages. To generate a Rivest-Shamir-Adelman (RSA) public key pair:

  • Open Terminal for Mac or Command Prompt for Windows,

  • Enter the following example command that will start the generation process in the dist/ directory.

yarn start \
  --name "Jane Doe" \
  --email "[email protected]" \
  --passphrase "123456789abcdef" \
  --type "rsa" \
  --curve "" \
  --bits 2048 \
  --expiration 0 \
  --format armored \
  --sign true

This starts generating a 2048-bit RSA key pair, encrypts them with the password provided and writes them to a file in the key directory with a pgp extension.


Generating a new Elliptic-curve cryptography (ECC) key pair

Elliptic-curve cryptography (ECC) is an alternative technique to RSA. It generates security between key pairs for public key encryption by using the mathematics of elliptic curves. Elliptic curve cryptography provides stronger security per bits of key, which allows for much faster operations.

Currently the following curves are supported:

| Curve | Encryption | Signature | NodeCrypto | WebCrypto | |:---------------:|:----------:|:---------:|:----------:|:---------:| | curve25519 | ECDH | N/A | No | No | | ed25519 | N/A | EdDSA | No | No | | p256 | ECDH | ECDSA | Yes | Yes | | p384 | ECDH | ECDSA | Yes | Yes | | p521 | ECDH | ECDSA | Yes | Yes | | brainpoolP256r1 | ECDH | ECDSA | Yes | No | | brainpoolP384r1 | ECDH | ECDSA | Yes | No | | brainpoolP512r1 | ECDH | ECDSA | Yes | No | | secp256k1 | ECDH | ECDSA | Yes | No |

To generate an Elliptic Curve Cryptography (ECC) key pair:

  • Open Terminal for Mac or Command Prompt for Windows,

  • Enter the following example command that will start the generation process in the dist/ directory.

yarn start \
  --name "Jane Doe" \
  --email "[email protected]" \
  --passphrase "123456789abcdef" \
  --type "ecc" \
  --curve curve25519 \
  --bits null \
  --expiration 0 \
  --format armored \
  --sign true

This starts generating an Elliptic Curve Cryptography (ECC) key pair, encrypts them with the password provided and writes them to a file in the key directory with a pgp extension.


Encrypting and Signing Data

Encryption is the transformation of data into a form in which it cannot be made sense of without the use of some key. Such transformed data is referred to as ciphertext.

Crypto Lib makes it easy and painless to encrypt and sign data.

To encrypt a message:

  • Open Terminal for Mac or Command Prompt for Windows,

  • Run the yarn start

  • Enter the following example command that will start the encryption process in the dist/ directory.

node dist/lib/encrypt.js \
  --passphrase '123456789abcdef' \
  --message 'Hello Crypto Service Suite APIs!'

Decrypting and Verifying Signatures

Decryption restores encrypted data to to its original (cleartext or plaintext) form. Decrypting data and verifying signatures is being done similarly in Crypto Lib.

To decrypt a message:

  • Open Terminal for Mac or Command Prompt for Windows,
  • Enter the following example command that will start the decryption process in the dist/ directory.
node dist/lib/decrypt.js \
  --passphrase '123456789abcdef' \
  --message 'LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgp3Y0ZNQXpMNWFTdVU0RWM4QVEvL1RlZzN6bzFiMSszNW9lN3l6NDFpRS9LVlNZYUJYSEFESTNpbVJodlQKeXlRczdFc29iYTdoUUx4dFZESjEyc3ZNU25YUWk2Y1FVNXd4cGo1L3VENUFOT2ZuN0hVSkYrSExINlRNCjNBWktZNUFLRk40VUZBK0hQRy9GSHlaNVhxVzRLd0hpL3ZjVWxSejRreWJDc2VxYmZoY01hU0NJdHR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ngzb2dYdTV0VFpvelRyUzRUMUpsMUR3bnRZbGlrMWhINkNYK0ZGLzIzVzlHaHdTdlcreVgzZFlTeHZjCjFuMlBjVDY5QzdDTmZtcWpOT293d20wcjl6M0lWYlZ2dGk4ZFduVzNEZDVGS256d2VaUDhaZ2hudUl4SQptUzdrY0ZWTVd4d3p6SmptQjg3UGZPbmZtZ2k2b0NxbFRzMXJDRldTQVZqM3hzenFFRGRnT1B1QXcvdzQKWmZOSS9sSVhHdU1DakpKQlYzNTZCN2ExNkZacXVqK2ZtOUQwS1BYbGpjSEcydHFRTjVDbHVTUnhUZlBiCm42U3ZOZ2tkVTNGM3pYS3NxRW9iRzdzakg5WjZWZlJIZjlRcmN2ZXZHdWFIb2ZZQkROVzZmT3ZNODBURQpHNjkzS3BRdytEaDVnMzBzamhXbDRuMS9aZUROR0RYZ0dERGRUMU9WQXRrVTBTcm1vY0ZSM1hCUHprYnQKRmw3YlVkVG1oVFlHVys2VmRIUG9mOFZ0b1FrWVJma2YxK1hFaC9kNUFvTzdSSVZRQ29qb3pqTmhoVy9qCjg4VW56d0VqZ3VoK0VMbVFRS1ViUi9ydjg2djcyM0VtVkVSd3hvQTIvalZCbGVaaHpFOHdrY01HODM3VApLVlo3N0VHblRPcTBjbUkrang2Ri9SenRjbDRBUHN6eEJkUkVSM25HR3dqbGVIdjdpMndhQTYzbWNJLzcKM0I0dWZyVGczbHNMWDVlWVFDUnJrdXdwOVZKNzNlWmJiOTlLOU51ZDhNVGczNnE0cFhtNWRBd3ZLZzEwCm96c0t2MHVxa0tDclF1TFBWU1JtZkE9PQo9Yll1VQotLS0tLUVORCBQR1AgTUVTU0FHRS0tLS0tCg=='

divider

🚥 Semantic Versioning Policy

For transparency into our release cycle and in striving to maintain backward compatibility, crypto-lib follows semantic versioning and ESLint's Semantic Versioning Policy.

divider

✅ Changelog

divider

❤️ Contributing

Thank you for using Crypto Lib! If you like the library, it would be great if you can give it a star ⭐ on GitHub.

There are also many ways in which you can participate in this project, for example:

divider

🥂 License

Copyright (c) Sebastien Rousseau. All rights reserved.

Licensed under the MIT license.

divider

🏢 Acknowledgements

Crypto Service Suite is beautifully crafted by these people and a bunch of awesome contributors.

| Contributors | |---------| |Sebastien Rousseau| |Sebastien Rousseau|