---
name: encryption-77336b520ce6
slug: encryption
version: 1.0.0
description: Encrypt files, secure passwords, manage keys, and audit code for cryptographic best practices.
homepage: https://clawic.com/skills/encryption
metadata:
  clawdbot:
    emoji: 🔐
    displayName: Encryption
---

## When to Use
- Encrypting files, database fields, or app storage
- Password hashing (bcrypt, argon2)
- Key management, rotation, derivation
- TLS/certificate configuration
- Auditing code for crypto mistakes
- Mobile secure storage (Keychain, Keystore)

## Algorithm Selection

| Purpose | Use | Avoid |
|---------|-----|-------|
| Passwords | argon2id, bcrypt (cost≥12) | MD5, SHA1, plain SHA256 |
| Symmetric | AES-256-GCM, ChaCha20-Poly1305 | AES-ECB, DES, RC4 |
| Asymmetric | RSA-4096+OAEP, Ed25519, P-256 | RSA-1024, PKCS#1 v1.5 |
| Key derivation | PBKDF2 (≥600k), scrypt, argon2 | Single-pass hash |
| JWT signing | RS256, ES256 | HS256 with weak secret |
| TLS | 1.2+ only | TLS 1.0/1.1, SSLv3 |

## Critical Rules

1. **Never reuse IVs/nonces** — AES-GCM + repeated nonce = catastrophic
2. **Use authenticated encryption (AEAD)** — Plain CBC enables padding oracles
3. **Hash passwords, don't encrypt** — Hashing is one-way
4. **No hardcoded keys** — Use env vars, KMS, or Vault
5. **No Math.random() for crypto** — Use CSPRNG only
6. **Constant-time comparisons** — Prevent timing attacks on secrets
7. **Separate keys by purpose** — Encryption ≠ signing ≠ backup

## File Encryption (CLI)

```bash
# age (modern, simple)
age -p -o file.age file.txt
age -d -o file.txt file.age

# GPG
gpg -c --cipher-algo AES256 file.txt
```

## Platform-Specific

See `patterns.md` for code snippets:
- Password hashing (Node, Python, Go)
- Envelope encryption with KMS
- JWT with RS256 key rotation
- Secure token generation

See `mobile.md` for:
- iOS Keychain wrapper
- Android EncryptedSharedPreferences
- SQLCipher setup
- Biometric auth integration
- Certificate pinning

See `infra.md` for:
- TLS certificate auto-renewal
- HashiCorp Vault policies
- mTLS between services
- Backup encryption verification

## Audit Checklist

- [ ] No plaintext passwords in DB/logs/env
- [ ] No secrets in git history
- [ ] No hardcoded keys in source
- [ ] No Math.random() for security
- [ ] No deprecated algorithms (MD5, SHA1, DES)
- [ ] No disabled cert validation
- [ ] IVs/nonces never reused
- [ ] PBKDF2 iterations ≥600k / bcrypt cost ≥12
- [ ] TLS 1.2+ enforced, old protocols disabled
- [ ] Key rotation procedure documented


---
Source attribution: clawic
Original project: https://github.com/clawic/skills/blob/f825206afbf1c697202533a9187be68c7b697e0e/skills/encryption/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2026 Ivan G. Davila

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: clawic
Original project: https://github.com/clawic/skills/blob/f825206afbf1c697202533a9187be68c7b697e0e/skills/encryption/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering
Roles: Backend Developer, DevOps / SRE, Security Engineer
Specialties: API, Backend
Tools: Age, Gpg
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: afe910ac0711c7cb667f2c482fb73b83017725b27da1d68ec3129a284438a7d4
