implementing-aes-encryption-for-data-at-rest

Implement AES-256-GCM encryption for files and data at rest with secure key derivation.

954|172|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/xalgord/xalgorix --skill implementing-aes-encryption-for-data-at-rest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: implementing-aes-encryption-for-data-at-rest
Source: https://github.com/xalgord/xalgorix/tree/main/internal/tools/skills/data/cryptography/implementing-aes-encryption-for-data-at-rest
Command: npx skills add https://github.com/xalgord/xalgorix --skill implementing-aes-encryption-for-data-at-rest

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires cryptography.

What problem does it solve?

Encrypting data at rest correctly is error-prone: developers often pick insecure modes like ECB, reuse nonces, skip authentication tags, or use raw passwords as keys. This Skill provides a vetted workflow for implementing AES-256-GCM encryption that resists tampering and avoids the most common cryptographic misconfigurations.

Core Features & Use Cases

  • Authenticated File Encryption: Encrypt and decrypt files with AES-256-GCM, storing salt, nonce, ciphertext, and tag in a defined binary format.
  • Secure Key Derivation: Derive keys from passwords using PBKDF2 (600k+ iterations) or Argon2id with per-file random salts.
  • Misconfiguration Detection: Verify implementations against known failures such as ECB mode, nonce reuse, missing MACs, and ignored authentication tags.
  • Use Case: A developer needs to encrypt sensitive configuration backups before writing them to disk. Use this Skill to derive a key with Argon2id, encrypt each file with a fresh 96-bit nonce, and confirm that tampered ciphertext is rejected on decryption.

Quick Start

Use the AES encryption skill to encrypt the file secrets.json with AES-256-GCM using a key derived from a password via Argon2id, then verify decryption rejects a tampered ciphertext.

Frequently Asked Questions about implementing-aes-encryption-for-data-at-rest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encrypt a file with AES-256 in Python?

Use the cryptography library with AES-256-GCM: derive a key from a password using PBKDF2 or Argon2id, generate a random 12-byte nonce with os.urandom, encrypt the data, and store salt, nonce, ciphertext, and tag together for later decryption.

What is the difference between AES-GCM and AES-CBC?

AES-GCM provides authenticated encryption (AEAD) with a built-in integrity tag, while AES-CBC provides no authentication and is vulnerable to padding-oracle attacks. For data at rest, prefer GCM; CBC should only appear in legacy systems with encrypt-then-HMAC.

Why is AES-ECB mode insecure for encrypting data?

AES-ECB encrypts identical plaintext blocks into identical ciphertext blocks, leaking data patterns (the ECB penguin problem). Detect it by encrypting repeated 16-byte blocks and checking for repeated ciphertext blocks; use AES-256-GCM instead.

Can I reuse a nonce in AES-GCM encryption?

No. Reusing a 96-bit nonce with the same key is catastrophic: it leaks the XOR of plaintexts and enables authentication-key recovery. Generate a fresh nonce with os.urandom(12) for every encryption and store it alongside the ciphertext.

How do I derive an encryption key from a password?

Never use a raw password as an encryption key. Derive keys with PBKDF2 using at least 600,000 iterations, or use Argon2id for memory-hard resistance, always with a random per-file salt stored with the ciphertext.

How do I verify my AES encryption detects tampering?

Flip one byte of the ciphertext or authentication tag and confirm decryption raises an InvalidTag error and returns no plaintext. A scheme that outputs data after tampering is broken; also confirm decryption with the wrong key fails.