Installations
npm install hybrid-crypto-js
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
13.8.0
NPM Version
6.13.7
Score
84.6
Supply Chain
99.3
Quality
75.9
Maintenance
50
Vulnerability
98.9
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
juhoen
Download Statistics
Total Downloads
499,737
Last Day
561
Last Week
3,487
Last Month
14,491
Last Year
136,902
GitHub Statistics
MIT License
142 Stars
208 Commits
40 Forks
7 Watchers
11 Branches
3 Contributors
Updated on Nov 26, 2024
Bundle Size
285.40 kB
Minified
76.00 kB
Minified + Gzipped
Package Meta Information
Latest Version
0.2.4
Package Id
hybrid-crypto-js@0.2.4
Unpacked Size
1.29 MB
Size
308.95 kB
File Count
22
NPM Version
6.13.7
Node Version
13.8.0
Total Downloads
Cumulative downloads
Total Downloads
499,737
Last Day
-4.8%
561
Compared to previous day
Last Week
-1.9%
3,487
Compared to previous week
Last Month
37.4%
14,491
Compared to previous month
Last Year
2.8%
136,902
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Hybrid Crypto JS
Introduction
Hybrid Crypto JS is a hybrid (RSA+AES) encryption and decryption toolkit for JavaScript. Hybrid Crypto JS combines RSA and AES encryption algorithms, making it possible to encrypt and decrypt large messages efficiently. This cross-platform library is based on Forge. Hybrid Crypto JS can be used in browsers, Node.js, or React Native.
Documentation
Getting started
Features
Installation
npm install hybrid-crypto-js
Importing
Node.js
1var RSA = require('hybrid-crypto-js').RSA; 2var Crypt = require('hybrid-crypto-js').Crypt;
React Native
1import { Crypt, RSA } from 'hybrid-crypto-js';
Web
Download minified hybrid-crypto.min.js file here.
1<script type="text/javascript" src="hybrid-crypto.min.js"></script>
Features
Initialization
1// Basic initialization
2var crypt = new Crypt();
3var rsa = new RSA();
4
5// Increase amount of entropy
6var entropy = 'Random string, integer or float';
7var crypt = new Crypt({ entropy: entropy });
8var rsa = new RSA({ entropy: entropy });
9
10// Select default message digest
11var crypt = new Crypt({ md: 'sha512' });
12
13// Select AES or RSA standard
14var crypt = new Crypt({
15 // Default AES standard is AES-CBC. Options are:
16 // AES-ECB, AES-CBC, AES-CFB, AES-OFB, AES-CTR, AES-GCM, 3DES-ECB, 3DES-CBC, DES-ECB, DES-CBC
17 aesStandard: 'AES-CBC',
18 // Default RSA standard is RSA-OAEP. Options are:
19 // RSA-OAEP, RSAES-PKCS1-V1_5
20 rsaStandard: 'RSA-OAEP',
21});
22
23// Alternate AES keysize (some AES algorithms requires specific key size)
24var crypt = new Crypt({
25 aesKeySize: 192, // Defaults to 256
26});
Encryption
Hybrid Crypto JS provides basic encryption function that also supports multiple RSA keys, with or without signature. An encrypted message is a JSON formatted string.
1var message = 'Hello world!'; 2 3// Encryption with one public RSA key 4var encrypted = crypt.encrypt(publicKey, message); 5 6// Function also supports encryption with multiple RSA public keys 7var encrypted = crypt.encrypt([publicKey1, publicKey2, publicKey3], message); 8 9// Encryption with signature 10var encrypted = crypt.encrypt(publicKey, message, signature);
Pretty-printed sample output
1{ 2 "v": "hybrid-crypto-js_0.1.2", // Current package version 3 "iv": "CmtyaZTyzoAp1mTNUTztic0v1...", // Initialization vector 4 "keys": { // Encrypted AES keys by RSA fingerprints 5 "85:3d:10:e1:56...": "bHaTF9...", 6 "d3:48:6a:e9:13...": "t9eds3..." 7 }, 8 "cipher": "+iwVFsC2dECBQvwcm9DND..." // Actual encrypted message 9 "signature": "sdL93kfdm12feds3C2..." // Signature (optional) 10} 11
Decryption
Decrypting message with Hybrid Crypto JS is as easy as encrypting. Decrypt function can decrypt any message which has been encrypted with key pair's public key. The decrypted message is a JSON object containing a message and an optional signature.
1var encrypted = '{"v":"hybrid-crypto-js_0.1.0","iv":"CmtyaZTyzoAp1mTN...'; 2 3// Decrypt encryped message with private RSA key 4var decrypted = crypt.decrypt(privateKey, encrypted); 5 6// Get decrypted message 7var message = decrypted.message;
Sample output
1{ 2 message: "Hello world!", // Actual decrypted message 3 signature: "sdL93kfdm12feds3C2..." // Signature (optional) 4}
Signatures
Hybrid Crypto JS provides simple message signing. The encrypted message can be signed with the issuer's private key.
1var message = 'Hello world!';
2
3// Create a signature with ISSUER's private RSA key
4var signature = crypt.signature(issuerPrivateKey, message);
5
6// Encrypt message with RECEIVERS public RSA key and attach the signature
7var encrypted = crypt.encrypt(receiverPublicKey, message, signature);
8
9// Select default message digest
10var crypt = new Crypt({
11 md: 'sha512', // Options: sha1, sha256, sha384, sha512, and md5
12});
Verifying
The message receiver needs to have a message issuer's public RSA key in order to verify the message issuer.
1// Encrypted message with signature 2var encrypted = '{"v":"hybri... ..."signature":"sdL93kfd...'; 3 4// Decrypt message with own (RECEIVER) private key 5var decrypted = crypt.decrypt(receiverPrivateKey, encrypted); 6 7// Verify message with ISSUER's public key 8var verified = crypt.verify( 9 issuerPublicKey, 10 decrypted.signature, 11 decrypted.message, 12);
Verification function returns true or false depending on whether the verification was successful.
RSA key pairs
Hybrid Crypto JS RSA key generation function is based in Forge key pair generation function. As a difference, Hybrid Crypto JS returns key pair in PEM format.
1// Initialize RSA-class 2var rsa = new RSA(); 3 4// Generate RSA key pair, default key size is 4096 bit 5rsa.generateKeyPair(function(keyPair) { 6 // Callback function receives new key pair as a first argument 7 var publicKey = keyPair.publicKey; 8 var privateKey = keyPair.privateKey; 9}); 10 11// ... or: 12rsa.generateKeyPairAsync().then(keyPair => { 13 var publicKey = keyPair.publicKey; 14 var privateKey = keyPair.privateKey; 15}); 16 17// Generate 1024 bit RSA key pair 18rsa.generateKeyPair(function(keyPair) { 19 // Callback function receives new 1024 bit key pair as a first argument 20 var publicKey = keyPair.publicKey; 21 var privateKey = keyPair.privateKey; 22}, 1024); // Key size 23 24// RSA can be also initialized with options 25var rsa = new RSA({ 26 keySize: 4096, 27});

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 2 are checked with a SAST tool
Reason
48 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-wg6g-ppvx-927h
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-92xj-mqp7-vmcj
- Warn: Project is vulnerable to: GHSA-wxgw-qj99-44c2
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
Score
1.7
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to hybrid-crypto-js
node-crypto-js
Node (RSA+AES) encryption and decryption companion for hybrid-crypto-js
@hyesungpark/hybrid-crypto-js
Hybrid (RSA+AES) encryption and decryption toolkit for JavaScript
@lakpriya2/hybrid-crypto
types for hybrid-crypto-js
@arthurcortezz/hybrid-crypto-js
Hybrid (RSA+AES) encryption and decryption toolkit for JavaScript