0.0.25 • Published 2 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 -S
import { 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
2 years ago
0.0.24
2 years ago
0.0.22
2 years ago
0.0.21
2 years ago
0.0.20
2 years ago
0.0.19
2 years ago
0.0.18
2 years ago
0.0.17
2 years ago
0.0.16
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.2
2 years ago