Commit Graph

1 Commits

Author SHA1 Message Date
peptiderepo
4770f0a861 security: encrypt OpenRouter API key at rest using AES-256-CBC
- Create PSA_Encryption class with AES-256-CBC encrypt/decrypt methods
- Derive encryption key from wp_salt('auth') using SHA-256 hash
- Prepend IV to ciphertext and base64-encode for safe storage
- Update PSA_Admin to encrypt API keys on save, mask on display
- Preserve existing key when empty/mask value submitted (no overwrite)
- Update PSA_AI_Generator to decrypt API key on read from database
- Maintain backward compatibility with plaintext keys (auto-encrypt on next save)
- Prefer wp-config constant over database value for maximum security

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 18:56:22 +07:00