@nova-lang/crypto
v0.1.0
Published
Nova cryptography library — hashing, HMAC, Base64, random UUIDs, AES encryption, and password utilities
Maintainers
Readme
@nova-lang/crypto
Nova cryptography library — hashing, HMAC, Base64, UUID generation, AES encryption, random utilities, and password helpers.
Install
npm install @nova-lang/cryptoUsage
@use "nova/crypto"Hash
| Function | Description |
|----------|-------------|
| crypto-hash-md5(data) | MD5 hex digest |
| crypto-hash-sha1(data) | SHA-1 hex digest |
| crypto-hash-sha256(data) | SHA-256 hex digest |
| crypto-hash-sha512(data) | SHA-512 hex digest |
| crypto-hash(algorithm, data) | Generic hash |
HMAC
| Function | Description |
|----------|-------------|
| crypto-hmac-sha256(key, data) | HMAC-SHA256 hex |
| crypto-hmac-sha512(key, data) | HMAC-SHA512 hex |
| crypto-hmac(algorithm, key, data) | Generic HMAC |
Base64
| Function | Description |
|----------|-------------|
| crypto-base64-encode(data) | Base64 encode |
| crypto-base64-decode(str) | Base64 decode |
| crypto-base64-url-encode(data) | URL-safe Base64 encode |
| crypto-base64-url-decode(str) | URL-safe Base64 decode |
Hex
| Function | Description |
|----------|-------------|
| crypto-hex-encode(data) | Hex encode |
| crypto-hex-decode(str) | Hex decode |
Random
| Function | Description |
|----------|-------------|
| crypto-random-bytes(size) | Random bytes buffer |
| crypto-random-hex(size) | Random hex string |
| crypto-random-base64(size) | Random base64 string |
| crypto-random-int(min, max) | Random integer (inclusive) |
| crypto-random-float() | Random float 0..1 |
UUID
| Function | Description |
|----------|-------------|
| crypto-uuid() | Generate UUID v4 |
| crypto-uuid-v4() | Generate UUID v4 |
AES Encryption
| Function | Description |
|----------|-------------|
| crypto-aes-encrypt(data, key, iv) | AES-256-CBC encrypt |
| crypto-aes-decrypt(encrypted, key, iv) | AES-256-CBC decrypt |
| crypto-aes-encrypt-gcm(data, key, iv) | AES-256-GCM encrypt |
| crypto-aes-decrypt-gcm(encrypted, key, iv) | AES-256-GCM decrypt |
Password
| Function | Description |
|----------|-------------|
| crypto-password-hash(password) | Salted PBKDF2 hash |
| crypto-password-verify(password, stored) | Verify against stored hash |
| crypto-pbkdf2(password, salt, iterations, keylen, digest) | PBKDF2 key derivation |
Utilities
| Function | Description |
|----------|-------------|
| crypto-timing-safe-eq(a, b) | Timing-safe comparison |
| crypto-object-hash(obj) | SHA-256 hash of serialized object |
License
MIT
