Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
An initialisation vector or nonce is the extra input that makes encrypting the same message twice produce different ciphertext. Reusing one is among the most damaging mistakes in applied cryptography.

What Are Initialisation Vectors and Nonces?
Encryption with a key alone is deterministic: the same plaintext always yields the same ciphertext, which leaks repetition to anyone watching. The initialisation vector, or nonce, is the extra input that breaks that pattern. It is not secret — it travels alongside the ciphertext in the clear — and it has exactly one job, which is to be different every time.
The two words are used loosely, and the distinction matters because the requirements differ. A nonce (number used once) must be unique under a given key. An IV, in the modes that use the term, must additionally be unpredictable. A salt, which is sometimes confused with both, is a public value used in key derivation rather than encryption.
| Mode | Value | Requirement | Consequence of failure |
|---|---|---|---|
| CBC | IV, 16 bytes | Unpredictable and unique | Chosen-plaintext attacks; confirmation of guessed plaintext |
| CTR | Nonce plus counter | Unique | Keystream reuse; plaintext recovery |
| GCM | Nonce, 12 bytes | Unique | Plaintext recovery and authentication key disclosure |
| XTS | Sector number as tweak | Unique per sector | Identical sectors become visible |
| GCM-SIV | Nonce, 12 bytes | Unique preferred, tolerable if reused | Only equality of messages leaks |
The CBC case is subtler than it looks. A predictable IV lets an attacker who can inject plaintext test guesses about other data in the same stream, which is how the BEAST attack worked against TLS 1.0 in 2011: the IV for each record was the previous record’s final ciphertext block, and therefore known in advance. TLS 1.1 fixed it by using an explicit random IV per record.
With AES-GCM, repeating a nonce under one key does two things. First, the XOR of the two ciphertexts equals the XOR of the two plaintexts, which often recovers both. Second, and far worse, an attacker can solve for the authentication subkey H, after which they can forge valid tags for messages you never wrote. One mistake converts a confidentiality failure into an integrity failure for everything protected by that key.
This is not a theoretical concern. It has been found in VPN implementations, in hardware with weak boot-time entropy, and repeatedly in containerised applications where a counter starts at zero on every restart and the key is a long-lived secret from the environment.
2^32 messages under one key, so rotate the key well before that — or, better, use a fresh data key per object as envelope encryption does.rand() or Math.random() supplying the value, which is a randomness failure as much as a nonce failure.All five are invisible in testing: the data encrypts, decrypts, and round-trips correctly. Only someone looking at the ciphertext, or at the code, notices. That is why cryptographic call sites are a standing item in our web application security services, and why storing the IV in plain sight next to the ciphertext is correct practice rather than a weakness.
No. IVs and nonces are designed to be public and are normally prepended to the ciphertext or stored in a header. Their security property is uniqueness, and for CBC also unpredictability, not secrecy. Trying to hide an IV adds no protection and usually complicates the code that has to retrieve it for decryption.
A nonce makes each encryption of the same plaintext produce different ciphertext, and is used once per message under a key. A salt makes each derivation of a key from the same password produce a different key, defeating precomputed tables. Both are public and random; they operate at different stages and are not interchangeable.
With random 96-bit nonces, keep below roughly 2^32 messages per key to stay clear of the birthday bound. With a guaranteed-unique counter the limit is far higher. The simplest answer in most architectures is to generate a new data key per object or per session, which removes the counting problem altogether.
No. In counter-based modes the keystream depends only on the key and nonce, so two different plaintexts encrypted under the same pair are both recoverable from their ciphertexts. In GCM it also exposes the authentication subkey. Uniqueness is a hard requirement regardless of what the plaintext contains.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.