0.0.25 • Published 3 years ago
code23-crypto v0.0.25
code23-crypto
Simple WebCrypto for Browser and Node. Supports simple functions for encrypting and decrypting data (RSA, AES) and hashing (SHA).
Installation
npm install code23-crypto -Simport { CryptoAes, CryptoRsa, CryptoSha } from "code23-crypto";Usage
AES (Advanced Encryption Standard, symmetric encryption)
const key = await CryptoAes.getKey("password");
const encrypted = await CryptoAes.encrypt(key, "Hello World");
const decrypted = await CryptoAes.decrypt(key, encrypted);RSA (Rivest–Shamir–Adleman, asymmetric encryption)
const keys = await CrytoRsa.generateKeys();
const encrypted = await CrytoRsa.encrypt(key.publicKey, "Hello World");
const decrypted = await CrytoRsa.decrypt(key.privateKey, encrypted);
const publicKeyBase64 = keys.publicKeyBase64;
const publicKey = await CrytoRsa.getPublicKeyFromBase64(publicKeyBase64);
const privateKeyBase64 = keys.privateKeyBase64;
const privateKey = await CrytoRsa.getPrivateKeyFromBase64(privateKeyBase64);SHA (Secure Hash Algorithm, hashing)
const sha = await CrytoSha.sha256("Hello World");
const shaBase64 = await CrytoSha.sha256ToBase64("Hello World");
const shaHex = await CrytoSha.sha256ToHex("Hello World");0.0.25
3 years ago
0.0.24
3 years ago
0.0.22
3 years ago
0.0.21
3 years ago
0.0.20
3 years ago
0.0.19
3 years ago
0.0.18
3 years ago
0.0.17
3 years ago
0.0.16
3 years ago
0.0.15
3 years ago
0.0.14
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.2
3 years ago