AES-GCM vs CBC vs ECB: Which Mode Should You Use?
AES-GCM, AES-CBC, and AES-ECB can all use the AES cipher, but they do not provide the same security properties or interoperability requirements.
Try it locally
Use the AES workspace to test documented values in your browser. Do not paste long-lived production secrets into a tool unless you understand and accept your device and browser risks.
Open the AES toolAES-GCM for new applications
GCM encrypts data and authenticates it in one construction. A recipient can detect an incorrect key, nonce, tag, or changed encrypted message. Use it as the default for newly designed applications when both systems support it.
AES-CBC for documented compatibility
CBC uses a 16-byte IV and padding, but encryption alone does not detect modification. It is useful only when you must reproduce a documented existing system. A production CBC protocol needs a separate, correctly verified authentication mechanism.
Why ECB is a legacy option
ECB encrypts matching plaintext blocks to matching ciphertext blocks. It can reveal patterns in structured data and does not use an IV. It is retained in this tool only to help inspect legacy values, not for new designs.
Quick checklist
- Use GCM for a new design.
- Use CBC only when a compatible existing system requires it.
- Use ECB only for a known legacy format and plan a migration away from it.
Common questions
Can I decrypt CBC ciphertext with GCM?
No. The mode, key, IV or nonce, padding, and ciphertext format must match the system that encrypted the value.
Does AES-256 make ECB safe?
No. Key length does not remove ECB's pattern leakage or add authentication.
Further reading: NIST block-cipher modes guidance