crypto-lib 0.0.2
Install from the command line:
Learn more about npm packages
$ npm install @sebastienrousseau/crypto-lib@0.0.2
Install via package.json:
"@sebastienrousseau/crypto-lib": "0.0.2"
About this version
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:
- Digital Signing,
- Encryption and Decryption,
- 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.
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.
Installation is done using either npm
, yarn
or pnpm
package managers to use Crypto Lib with Node.js or the Command Line Interface:
npm i @sebastienrousseau/crypto-lib
yarn add @sebastienrousseau/crypto-lib
pnpm add @sebastienrousseau/crypto-lib
Within the download you'll find all the crypto lib source files grouped into the dist folder.
You'll see something like this:
.
├── bin
│ ├── crypto-lib.d.ts
│ ├── crypto-lib.d.ts.map
│ ├── crypto-lib.js
│ └── crypto-lib.js.map
├── index.d.ts
├── index.d.ts.map
├── index.js
├── index.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
├── revoke-key.d.ts
├── revoke-key.d.ts.map
├── revoke-key.js
└── revoke-key.js.map
2 directories, 24 files
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 "jane@doe.com" \
--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 "jane@doe.com" \
--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 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 'LS0tLS1CRUdJTiBQR1AgTUVTU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ZLZzEwCm96c0t2MHVxa0tDclF1TFBWU1JtZkE9PQo9Yll1VQotLS0tLUVORCBQR1AgTUVTU0FHRS0tLS0tCg=='
Details
- crypto-lib
-
sebastienrousseau
- almost 3 years ago
- MIT
- 27 dependencies
Assets
- crypto-lib-0.0.2-npm.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0