Key and nonce in one step
AES needs a secret key and, in most modes, a unique value per message: a 96-bit nonce for GCM or a 128-bit IV for CBC and CTR. This generator creates both, so you have everything for a test vector, a configuration file or a quick experiment.
The key is the secret part. The nonce or IV is not secret and is usually stored next to the ciphertext, but it must never repeat with the same key. With GCM, reusing a nonce breaks both confidentiality and authentication.
Choosing a mode
- GCM is the default and the best choice for new code. It encrypts and authenticates in one step.
- CBC needs a random, unpredictable IV for every message and a separate MAC to detect tampering. Use it only for compatibility.
- CTR needs a unique counter block for every message and, like CBC, a separate MAC.
Frequently asked questions
Should I use AES-128 or AES-256?
Both are secure. AES-256 is the common default and gives extra margin against future attacks, at a small speed cost.
Should I make a new nonce here for every message?
In a real system, generate the nonce in your code at encryption time. This page is meant for keys, test vectors and one-off use.