Package Exports
- scryptex
- scryptex/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scryptex) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Installation
NPM
npm i scryptex
import * as SCryptex from "index"; // esm
const SCryptex = require("index"); // cjs
Hash
let data = "test", data0 = data, data1 = "Test";
let h = SCryptex.hash(data); // data will be hashed
console.log(SCryptex.compareHash(data0, h)); // true
console.log(SCryptex.compareHash(data1, h)); // false
RSA
Generating key pair
let {privateKey, publicKey} = SCryptex.generateRSAKeyPair();
Encrypting
let encrypted = SCryptex.RSAEncrypt(data, publicKey); // data will be encrypted
Decrypting
let decrypted = SCryptex.RSADecrypt(encrypted, privateKey);
Generating keys and encrypting
let {privateKey, publicKey, data: encrypted} = SCryptex.RSAEncrypt(data); // data will be encrypted
RSA class
let rsa = new SCryptex.RSA(); // Keys will be generated
let rsa = new SCryptex.RSA(publicKey, privateKey); // or with generated keys
let rsa = new SCryptex.RSA(publicKey); // or with public key (Decryption is not available)
Encrypting
let encrypted = rsa.encrypt(data); // data will be encrypted
Decrypting
let decrypted = rsa.decrypt(encrypted);