Age is a modern file encryption tool that’s simple yet powerful. Here’s how to decrypt age-encrypted files using a secret key.

Prerequisites

  • age installed on your system
  • An encrypted file (base64 encoded)
  • A secret key (starting with AGE-SECRET-KEY-)

Step-by-Step Decryption

  1. First, decode the base64 content to a file:
echo "YOUR-BASE64-CONTENT" | base64 -d > encrypted.age
  1. Save the secret key to a file:
echo "AGE-SECRET-KEY-YOUR-KEY" > key.txt
chmod 600 key.txt  # Set proper permissions
  1. Decrypt the file:
age --decrypt -i key.txt encrypted.age

Installing age

Choose your platform:

  • macOS: brew install age
  • Ubuntu/Debian: apt install age
  • Other systems: Download from the age GitHub repository

Common Issues

  • Ensure you’re using only the AGE-SECRET-KEY line for decryption
  • Verify the base64 content is complete and properly formatted
  • Check file permissions on the key file (should be readable only by you)

Security Best Practices

  • Never share your secret key
  • Delete key files after use
  • Store encrypted files and keys separately
  • Use secure channels when transferring encrypted files