@forgeframework/crypto
v0.3.0
Published
Provides cryptographic utilities for the Forge Framework.
Downloads
690
Maintainers
Readme
@forgeframework/crypto
Provides cryptographic utilities for the Forge Framework.
Part of the Forge Framework — a TypeScript framework for backend microservices and web applications.
Installation
npm install @forgeframework/cryptoUsage
import { PasswordHasher, SymmetricEncryption, TokenGenerator, Hmac, Hash } from '@forgeframework/crypto';
const hasher = new PasswordHasher({ algorithm: 'argon2id' });
const hashed = await hasher.hash('user-password');
const valid = await hasher.verify('user-password', hashed);
const encryption = new SymmetricEncryption({ algorithm: 'aes-256-gcm' });
const encrypted = encryption.encrypt('sensitive data', encryptionKey);
const decrypted = encryption.decrypt(encrypted, encryptionKey);
const resetToken = TokenGenerator.randomBase64Url(32);
const otp = TokenGenerator.otp(6);
const signature = Hmac.sign(payload, webhookSecret);
const isValid = Hmac.verify(payload, signature, webhookSecret);
const checksum = Hash.sha256(fileContent);Documentation
Full API reference and guides: https://carbonforge.io/framework/docs/security/crypto
(Documentation site launching soon.)
License
MIT © Carbon Forge
