An open API service indexing awesome lists of open source software.

https://github.com/chadnpc/cryptobase

🔥 Provides classes to speed up your cryptographic needs.
https://github.com/chadnpc/cryptobase

cryptographic-algorithms

Last synced: 6 days ago
JSON representation

🔥 Provides classes to speed up your cryptographic needs.

Awesome Lists containing this project

README

          

## [cryptobase](https://www.powershellgallery.com/packages/cryptobase)

🔥 Provides classes to speed up your cryptographic needs.

[![Downloads](https://img.shields.io/powershellgallery/dt/cryptobase.svg?style=flat&logo=powershell&color=blue)](https://www.powershellgallery.com/packages/cryptobase)

**Features**

- **AEAD Encryption**: AES-GCM, AES-CCM, AES-OCB, and XChaCha20-Poly1305.
- **Hashing & MACs**: BLAKE3, SHA-3 (Keccak), BLAKE2b, KMAC, HMAC.
- **Password Hashing**: Argon2 (id/i/d), Scrypt, BCrypt (with SHA-3 extensions), PBKDF2.
- **Elliptic Curve Cryptography**: Ed25519, Curve25519, Secp256k1 (Bitcoin/Ethereum).
- **Post-Quantum Cryptography (PQC)**: ML-KEM (Kyber), ML-DSA (Dilithium), SLH-DSA (Sphincs+).
- **Advanced Protocols**: OPAQUE (PAKE), Noise Protocol Framework, OpenPGP Armor.
- **Utilities**: OTP (TOTP/HOTP), Key Derivation (HKDF), Credentials Management, File Obfuscation.

**📦 Installation**

```PowerShell
# Install from PSGallery
Install-Module cryptobase -Scope CurrentUser

# Import the module
Import-Module cryptobase
```

**🗐 Testing (before opening a PR)**

```PowerShell
Import-Module ./cryptobase.psd1
./Test-Module.ps1 -SkipBuildOutput
```

or test the `./BuildOutput/`

```PowerShell
./Test-Module.ps1
```

**💡 Quick Examples**

**High-Level Data Protection**
Easily encrypt and decrypt data with a password using the main `[CryptoBase]` class.

```powershell
$password = [secureString][System.Net.NetworkCredential]::new("", "my-ultra-secure-password").SecurePassword
$data = [System.Text.Encoding]::UTF8.GetBytes("Hello World")

# Encrypt (uses Argon2id + AES-256-GCM)
$encrypted = [CryptoBase]::ProtectData($data, $password)

# Decrypt
$decrypted = [CryptoBase]::UnprotectData($encrypted, $password)
[System.Text.Encoding]::UTF8.GetString($decrypted) # i.e: you get back "Hello World"
```

**Modern Hybrid Cascades**
Paranoid double-wrap mode with independent keys for AES-256-GCM and XChaCha20-Poly1305.

```powershell
$password = [secureString][System.Net.NetworkCredential]::new("", "my-ultra-secure-password").SecurePassword
$data = [System.Text.Encoding]::UTF8.GetBytes("Top secret")
$cascade = [CryptoBase]::ProtectDataCascade($data, $password)
$plain = [CryptoBase]::UnprotectDataCascade($cascade, $password)
[system.text.Encoding]::UTF8.GetString($plain) # i.e: you get back "Top secret"
```

**Post-Quantum Hybrids**
Hybrid encryption that combines NIST P-256 ECDH with ML-KEM encapsulation.

```powershell
$recipientP256 = [Curve25519]::GenerateKeyPair()
$recipientKem = [MLKemCore]::GenerateKeyPair()
$payload = [System.Text.Encoding]::UTF8.GetBytes("future-proof")
$hybrid = [CryptoBase]::ProtectDataQuantumHybrid($payload, $recipientP256.PublicKey, $recipientKem.PublicKey)
```

**Password Hashing (BCrypt)**
Standard password hashing for your applications.

```powershell
clihelper.core\Wait-Task "H4sH1N9" { param([string]$secret) return [BCrypt]::HashPassword($secret) } 'my_secret'
Wait-Task "H4sH1N9" { param([string]$secret) return [BCrypt]::HashPassword($secret) } 'my_secret'
$isValid = [BCrypt]::Verify('my_secret', $hash) # Returns $true
```

**📚 Documentation**

For a complete list of classes and their usage, see:

- **[More about the main class](./docs/CryptoBase.md)** and cmdlet overview.
- **[More usage docs](./docs/README.md)**: Categorized list of all major primitives.
- **[OPAQUE Protocol](./docs/Opaque.md)**: Detailed guide for secure password authentication.

**⚖️ License**

This project is licensed under the [MIT License](LICENSE).