crypto-lib 0.0.3
Install from the command line:
Learn more about npm packages
$ npm install @sebastienrousseau/crypto-lib@0.0.3
Install via package.json:
"@sebastienrousseau/crypto-lib": "0.0.3"
About this version
Website • Documentation • Submit an Issue • Contributing Guidelines
Crypto Lib is a powerful intuitive cryptographic JavaScript library that encapsulates common algorithms, functions and provides an interface for low-level cryptographic operations.
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.
👉 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.
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.
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!
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.
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.
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.
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!'
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 'LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tCgp3Y0ZNQXpMNWFTdVU0R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E9PQo9Yll1VQotLS0tLUVORCBQR1AgTUVTU0FHRS0tLS0tCg=='
For transparency into our release cycle and in striving to maintain backward
compatibility, crypto-lib
follows semantic versioning
and ESLint's Semantic Versioning Policy.
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:
- Submit bugs and feature requests, and help us verify as they are checked in,
- Review source code changes, and help us improve our code quality,
- Review the documentation and make pull requests for anything from typos to additional and new content.
Copyright (c) Sebastien Rousseau. All rights reserved.
Licensed under the MIT license.
Crypto Service Suite is beautifully crafted by these people and a bunch of awesome contributors.
Contributors |
---|
Sebastien Rousseau |
Details
- crypto-lib
-
sebastienrousseau
- about 3 years ago
- MIT
- 36 dependencies
Assets
- crypto-lib-0.0.3-npm.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0