aes-encryption.com
English

AES · GCM / CBC / CTR

AES IV and Nonce: Length, Uniqueness and Saving

Learn the different GCM nonce, CBC IV and CTR counter requirements and which values must accompany ciphertext.

The terms depend on the mode

GCM uses a nonce, CBC an initialization vector, and CTR an initial counter block. The interface groups them as IV / nonce / counter, but their requirements are not interchangeable. Here GCM takes 12 bytes; CBC and CTR take 16. Count decoded bytes, not the length of a Base64 string.

An IV or nonce is generally not the secret key. It must be saved for recovery and obey its mode's generation requirements. Concealing an IV does not repair reuse, a weak key or missing authentication.

Fresh values and reuse hazards

With GCM, never reuse a nonce with the same key. CBC requires an unpredictable IV. CTR must avoid repeated counter blocks under the same key. This tool generates a fresh value for raw encryption unless you deliberately enable manual compatibility parameters. The password profile also creates a fresh salt and nonce every time.

Manual values are useful for published test vectors or reproducing an existing system. They should not be copied into production code as a fixed IV. The tool cannot know the full history of a key used elsewhere, so it cannot certify that a manually entered value has never been used.

Encoding example

A 12-byte GCM nonce is 24 Hex digits or 16 standard Base64 characters. A 16-byte CBC IV is 32 Hex digits or 24 Base64 characters including padding. Entering the visible characters of a Hex string as UTF-8 produces different bytes. Match the peer's encoding before evaluating the length error.

CTR in this tool fixes a 64-bit low-order counter and rejects wrap across the message. A 16-byte input alone does not tell you which part another library increments.

Save the values without exposing the key

The password package saves its nonce and salt outside ciphertext because decryption needs them. Original file names are different: this site puts them inside the encrypted record. For raw mode, the parameter download includes the IV and AAD but excludes the key. Store the key separately and keep the exact encoding labels with the record.

Technical references

Updated October 16, 2026

Frequently asked questions

Must an IV be kept secret?

Not normally. It must obey the selected mode's requirements and remain available for decryption. Its visibility does not make nonce reuse acceptable.

Can I use the same IV if the password is unchanged?

Do not manually reuse it. The password profile creates a new salt and nonce for each encryption; the tool does not offer fixed password-profile IVs.