All Projects → juhoen → Hybrid Crypto Js

juhoen / Hybrid Crypto Js

Licence: mit
RSA+AES hybrid encryption implementation for JavaScript. Works with Node.js, React Native and modern browsers.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Hybrid Crypto Js

Jsrsasign
The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES JSON Web Signature/Token in pure JavaScript.
Stars: ✭ 2,760 (+3072.41%)
Mutual labels:  encryption, aes, rsa, decryption
Laravel Database Encryption
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Stars: ✭ 238 (+173.56%)
Mutual labels:  encryption, aes, decryption, encrypt
Encryptor4j
Strong encryption for Java simplified
Stars: ✭ 92 (+5.75%)
Mutual labels:  encryption, aes, rsa, decryption
Padding Oracle Attacker
🔓 CLI tool and library to execute padding oracle attacks easily, with support for concurrent network requests and an elegant UI.
Stars: ✭ 136 (+56.32%)
Mutual labels:  encryption, aes, decryption
Hat.sh
encrypt and decrypt files in your browser. Fast, Secure client-side File Encryption and Decryption using the web crypto api
Stars: ✭ 886 (+918.39%)
Mutual labels:  encryption, aes, decryption
Cross Platform Aes
Simple cross-platform encryption and decryption using AES
Stars: ✭ 127 (+45.98%)
Mutual labels:  encryption, aes, decryption
Encrypt
🔒 A set of high-level APIs over PointyCastle for two-way cryptography.
Stars: ✭ 199 (+128.74%)
Mutual labels:  encryption, aes, rsa
common-secure
提供一些加密算法java代码封装 包括 RSA/AES/DES/3DES/MD5/SHA/HmacSHA256
Stars: ✭ 37 (-57.47%)
Mutual labels:  aes, rsa, encrypt
EasyAES
AES encrypt/decrypt, Android, iOS, php compatible(兼容php, Android, iOS平台)
Stars: ✭ 79 (-9.2%)
Mutual labels:  encryption, aes, decryption
Aes Rsa Java
AES+RSA结合应用java示例
Stars: ✭ 295 (+239.08%)
Mutual labels:  encryption, aes, rsa
Netcore.encrypt
NETCore encrypt and decrpty tool,Include aes,des,rsa,md5,sha1,sha256,sha384,sha512
Stars: ✭ 339 (+289.66%)
Mutual labels:  aes, rsa, encrypt
Py7zr
7zip in python3 with ZStandard, PPMd, LZMA2, LZMA1, Delta, BCJ, BZip2, and Deflate compressions, and AES encryption.
Stars: ✭ 110 (+26.44%)
Mutual labels:  encryption, aes, decryption
Swcrypt
RSA public/private key generation, RSA, AES encryption/decryption, RSA sign/verify in Swift with CommonCrypto in iOS and OS X
Stars: ✭ 632 (+626.44%)
Mutual labels:  aes, rsa, encrypt
Underlock
Underlock makes it dead simple to encrypt and decrypt your data and files. It comes with little to no dependencies and has a very small API surface.
Stars: ✭ 128 (+47.13%)
Mutual labels:  encryption, decryption, encrypt
Encrypt Body Spring Boot Starter
(停止维护,替代品搜索:https://github.com/search?l=Java&q=encrypt&type=Repositories )SpringBoot控制器统一的响应体加密与请求体解密的注解处理方式,支持MD5/SHA/AES/DES/RSA
Stars: ✭ 198 (+127.59%)
Mutual labels:  aes, rsa, encrypt
Python-File-Encryptor
Encrypt and Decrypt files using Python (AES CBC MODE)
Stars: ✭ 51 (-41.38%)
Mutual labels:  encryption, aes, decryption
Gonnacry
A Linux Ransomware
Stars: ✭ 341 (+291.95%)
Mutual labels:  encryption, aes, decryption
Xjar
Spring Boot JAR 安全加密运行工具,支持的原生JAR。
Stars: ✭ 692 (+695.4%)
Mutual labels:  encryption, aes, decryption
Enigma
Enigma cipher tool
Stars: ✭ 13 (-85.06%)
Mutual labels:  encryption, decryption
Java Crypto Utils
Java Cryptographic, Encoding and Hash Utilities
Stars: ✭ 15 (-82.76%)
Mutual labels:  encryption, decryption

Hybrid Crypto JS

NPM

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

var RSA = require('hybrid-crypto-js').RSA;
var Crypt = require('hybrid-crypto-js').Crypt;

React Native

import { Crypt, RSA } from 'hybrid-crypto-js';

Web

Download minified hybrid-crypto.min.js file here.

<script type="text/javascript" src="hybrid-crypto.min.js"></script>

Features

Initialization

// Basic initialization
var crypt = new Crypt();
var rsa = new RSA();

// Increase amount of entropy
var entropy = 'Random string, integer or float';
var crypt = new Crypt({ entropy: entropy });
var rsa = new RSA({ entropy: entropy });

// Select default message digest
var crypt = new Crypt({ md: 'sha512' });

// Select AES or RSA standard
var crypt = new Crypt({
    // Default AES standard is AES-CBC. Options are:
    // AES-ECB, AES-CBC, AES-CFB, AES-OFB, AES-CTR, AES-GCM, 3DES-ECB, 3DES-CBC, DES-ECB, DES-CBC
    aesStandard: 'AES-CBC',
    // Default RSA standard is RSA-OAEP. Options are:
    // RSA-OAEP, RSAES-PKCS1-V1_5
    rsaStandard: 'RSA-OAEP',
});

// Alternate AES keysize (some AES algorithms requires specific key size)
var crypt = new Crypt({
    aesKeySize: 192, // Defaults to 256
});

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.

var message = 'Hello world!';

// Encryption with one public RSA key
var encrypted = crypt.encrypt(publicKey, message);

// Function also supports encryption with multiple RSA public keys
var encrypted = crypt.encrypt([publicKey1, publicKey2, publicKey3], message);

// Encryption with signature
var encrypted = crypt.encrypt(publicKey, message, signature);

Pretty-printed sample output

{
    "v": "hybrid-crypto-js_0.1.2",        // Current package version
    "iv": "CmtyaZTyzoAp1mTNUTztic0v1...", // Initialization vector
    "keys": {                             // Encrypted AES keys by RSA fingerprints
        "85:3d:10:e1:56...": "bHaTF9...",
        "d3:48:6a:e9:13...": "t9eds3..."
    },
    "cipher": "+iwVFsC2dECBQvwcm9DND..."  // Actual encrypted message
    "signature": "sdL93kfdm12feds3C2..."  // Signature (optional)
}

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.

var encrypted = '{"v":"hybrid-crypto-js_0.1.0","iv":"CmtyaZTyzoAp1mTN...';

// Decrypt encryped message with private RSA key
var decrypted = crypt.decrypt(privateKey, encrypted);

// Get decrypted message
var message = decrypted.message;

Sample output

{
    message: "Hello world!",            // Actual decrypted message
    signature: "sdL93kfdm12feds3C2..."  // Signature (optional)
}

Signatures

Hybrid Crypto JS provides simple message signing. The encrypted message can be signed with the issuer's private key.

var message = 'Hello world!';

// Create a signature with ISSUER's private RSA key
var signature = crypt.signature(issuerPrivateKey, message);

// Encrypt message with RECEIVERS public RSA key and attach the signature
var encrypted = crypt.encrypt(receiverPublicKey, message, signature);

// Select default message digest
var crypt = new Crypt({
    md: 'sha512', // Options: sha1, sha256, sha384, sha512, and md5
});

Verifying

The message receiver needs to have a message issuer's public RSA key in order to verify the message issuer.

// Encrypted message with signature
var encrypted = '{"v":"hybri... ..."signature":"sdL93kfd...';

// Decrypt message with own (RECEIVER) private key
var decrypted = crypt.decrypt(receiverPrivateKey, encrypted);

// Verify message with ISSUER's public key
var verified = crypt.verify(
    issuerPublicKey,
    decrypted.signature,
    decrypted.message,
);

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.

// Initialize RSA-class
var rsa = new RSA();

// Generate RSA key pair, default key size is 4096 bit
rsa.generateKeyPair(function(keyPair) {
    // Callback function receives new key pair as a first argument
    var publicKey = keyPair.publicKey;
    var privateKey = keyPair.privateKey;
});

// ... or:
rsa.generateKeyPairAsync().then(keyPair => {
    var publicKey = keyPair.publicKey;
    var privateKey = keyPair.privateKey;
});

// Generate 1024 bit RSA key pair
rsa.generateKeyPair(function(keyPair) {
    // Callback function receives new 1024 bit key pair as a first argument
    var publicKey = keyPair.publicKey;
    var privateKey = keyPair.privateKey;
}, 1024); // Key size

// RSA can be also initialized with options
var rsa = new RSA({
    keySize: 4096,
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].