Skip to content
uencoder
TUTORIAL

How to Decrypt with AES

Decrypt AES ciphertext using the correct key, IV, and mode, and verify integrity for authenticated modes.

Problem

You have AES-encrypted ciphertext and the key, and need to recover the original plaintext.

Prerequisites

  • Understanding of AES encryption
  • Knowledge of the mode and IV used for encryption

Steps

  1. 1. Gather all parameters

    You need the key, the IV (or nonce), the ciphertext, and the mode used during encryption. For GCM, you also need the authentication tag. All of these must match what was used to encrypt.

    Input
    key + IV + ciphertext + mode
    Output
    ready to decrypt
  2. 2. Verify the authentication tag (GCM)

    If the data was encrypted with GCM, verify the tag before decrypting. If the tag does not match, the ciphertext has been tampered with and must be rejected. Do not attempt to use tampered data.

    Input
    tag mismatch
    Output
    reject: data corrupted
  3. 3. Decrypt and interpret the result

    Decrypt the ciphertext using the key and IV. If the result is text, decode it with the correct character set. If it is binary, save it as a file. A wrong key produces garbage without error in non-authenticated modes.

    Input
    ciphertext + correct key
    Output
    original plaintext

Expected result

The original plaintext, verified for integrity if an authenticated mode was used.

Common errors

Decryption succeeds but output is garbage
In CBC or CTR mode, a wrong key produces random-looking output without error. Use GCM to detect wrong keys via tag verification.
Wrong IV produces partially correct output
The IV affects only the first block in CBC. A wrong IV corrupts the first block but leaves the rest intact. Verify the IV matches.

Troubleshooting

  • If only the first block is corrupted, the IV is wrong but the key is correct.
  • If all blocks are garbage, the key or mode is wrong.

Security limits

  • Never use decrypted data without verifying the authentication tag in GCM mode.
  • All decryption happens locally. No data is sent to any server.

Related tools

Related glossary

Related tasks

Ready to run it?

References