aes-256-xts encrypt & decrypt online
Encrypt or decrypt text with aes-256-xts and a secret. Same result as PHP's openssl_encrypt, and nothing leaves your browser.
The bytes behind your result
Your code gives a different result? Almost always the key or the IV differ. Here you see exactly which bytes the tool used for the secret and text in the tool above: copy the key and IV in hex into your own code. Shown for the text The quick brown fox jumps over the lazy dog and the secret my secret until you type above.
- Key · 64 bytes 9 from your secret, 55 zero bytes added
- 6d792073656372657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6d792073656372657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 - IV · 16 bytes none given, so zero bytes
- 00000000000000000000000000000000
00000000000000000000000000000000 - Text in UTF-8 43 bytes, no padding needed
- 54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67
- Encrypted · 43 bytes
- 7f9795709c93f949921cbfa87e869858007016b2a9eb61fa89d29bd2974ac3ebc09c1c4ca59c876fc31b24
7f9795709c93f949921cbfa87e869858007016b2a9eb61fa89d29bd2974ac3ebc09c1c4ca59c876fc31b24 - As Base64 what the tool shows
f5eVcJyT+UmSHL+ofoaYWABwFrKp62H6idKb0pdKw+vAnBxMpZyHb8MbJA==
from your inputzero bytesciphertext
What is aes-256-xts?
AES is the block cipher NIST standardised in 2001 (FIPS 197), originally called Rijndael. It is the most widely used cipher today and has no practical attack. AES-256-XTS uses a 256-bit key (14 rounds) in XEX with ciphertext stealing mode: made for disk encryption, with two keys and the sector number as IV.
How your secret becomes the key
XTS takes two keys of 32 bytes, so the tool needs 64 bytes. Your secret is padded with zero bytes to 64 bytes or cut after 64 bytes; the first 32 bytes are the data key, the rest is the tweak key.
- HTTPS and TLS
- Wi-Fi (WPA2, WPA3)
- Disk encryption: BitLocker, FileVault, LUKS
- VPNs, ZIP and 7-Zip archives, password managers
Is it safe to use?
AES. No practical attack on the cipher itself is known.
The setup of this tool is made for compatibility with PHP's openssl_encrypt, not for protecting secrets: the IV is always zero, the secret is used as the key without a key derivation function, and nothing detects changes to the ciphertext.
For real secrets use an authenticated mode such as AES-256-GCM or ChaCha20-Poly1305 with a fresh random nonce for every message, and derive the key from a password with Argon2id, scrypt or PBKDF2. What is a key derivation function?
How XTS mode works
XTS (IEEE 1619, NIST SP 800-38E) is made for encrypting disk sectors. The key is two keys of the same length: one encrypts the data, the other encrypts the sector number (the "tweak", here the IV) to make each sector different.
Input must be at least 16 bytes; a last partial block is handled by ciphertext stealing, so there is no padding. OpenSSL refuses to encrypt if both key halves are equal, which happens here with an empty secret.
The same result in your code
Every snippet prints f5eVcJyT+UmSHL+ofoaYWABwFrKp62H6idKb0pdKw+vAnBxMpZyHb8MbJA== for the text The quick brown fox jumps over the lazy dog and the secret my secret, the same as the tool. The key and IV are written out in hex, so you can see what the tool does with the secret. Your own key and IV are in What the tool did. All snippets are run against PHP before each release.
$key = hex2bin("6d792073656372657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"); // "my secret" padded with zero bytes to 64 bytes $iv = hex2bin("00000000000000000000000000000000"); // no IV given: 16 zero bytes echo openssl_encrypt("The quick brown fox jumps over the lazy dog", "aes-256-xts", $key, 0, $iv);
Shortest form, same result: openssl_encrypt("The quick brown fox jumps over the lazy dog", "aes-256-xts", "my secret"). PHP pads the secret itself but warns about the empty IV.
# pip install cryptography import base64 from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes key = bytes.fromhex("6d792073656372657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") # "my secret" padded with zero bytes to 64 bytes iv = bytes(16) # no IV given: 16 zero bytes data = "The quick brown fox jumps over the lazy dog".encode() enc = Cipher(algorithms.AES(key), modes.XTS(iv)).encryptor() print(base64.b64encode(enc.update(data) + enc.finalize()).decode())
Python has no AES in the standard library; cryptography is the common package for it.
import { createCipheriv } from 'node:crypto'; const key = Buffer.from("6d792073656372657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 'hex'); // "my secret" padded with zero bytes to 64 bytes const iv = Buffer.alloc(16); // no IV given: 16 zero bytes const c = createCipheriv("aes-256-xts", key, iv); console.log(Buffer.concat([c.update("The quick brown fox jumps over the lazy dog", 'utf8'), c.final()]).toString('base64'));
Why your aes-256-xts result doesn't match
XTS needs at least 16 bytes of input. Shorter texts give no result. An empty secret makes both key halves zero, which OpenSSL refuses.
Many tutorials turn a password into a key with SHA-256 or MD5. This tool doesn't: it uses the bytes of your secret directly and pads them with zero bytes. Copy the key in hex from What the tool did and use it as the raw key.
With a random IV the result changes every time. The tool uses no IV, which in PHP means zero bytes. Use a zero IV of the right length to get the same result, and keep the random IV for real data.
The tool shows the raw ciphertext bytes as Base64. Many libraries return hex or raw bytes. Convert before comparing, or compare with the hex blocks in What the tool did.
Like the old site, the tool trims spaces and line breaks at the start and end of the text and the secret, and sends line breaks as CRLF (\r\n), as a browser form does. echo "text" | in a shell adds a line break at the end.
Only the first bytes up to the key length count, the rest is cut off. Two secrets that start with the same bytes give the same result. Non-ASCII characters take 2–4 bytes in UTF-8, so they fill the key faster.
Given a password, the openssl command line derives key and IV from it with a random salt (EVP_BytesToKey or PBKDF2), and the output starts with U2FsdGVkX1 ("Salted__"). That is a different format. Pass the key and IV in hex with -K and -iv instead, as in the code example.
Encrypted something here years ago?
Paste the Base64 result and the secret. Your browser tries all 174 ciphers of this site and shows those that give readable text. Useful if you don't remember the cipher, or to check whether your ciphertext really is aes-256-xts.
Every AES-256 variant, same input
The text The quick brown fox jumps over the lazy dog (43 bytes) with the secret my secret in all 19 AES-256 ciphers. The last column lists names that give the same result: aliases, and modes that agree for this input. Highlighted: the same start as aes-256-xts. Watch how CBC and ECB share the first block, and CFB, OFB and CTR the first 16 bytes. Type a text and a secret in the tool above to use yours.
| Cipher | Result (Base64) | Same as |
|---|---|---|
| aes-256-cbc | oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeW | aes-256-cbc-hmac-sha1, aes-256-cbc-hmac-sha256, aes256 |
| aes-256-cbc-hmac-sha1 | oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeW | aes-256-cbc, aes-256-cbc-hmac-sha256, aes256 |
| aes-256-cbc-hmac-sha256 | oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeW | aes-256-cbc, aes-256-cbc-hmac-sha1, aes256 |
| aes-256-ccm | no result | |
| aes-256-cfb | 1ktyGwyrPTtkgyEyM7E0vd7s0sNfMxpZ1+JmL66k6iOQDRetJtUIxxMdXg== | |
| aes-256-cfb1 | xnZa43U4+GFN07PHLjjTWL93kLi0GAONkmwZ2ChIWqMhmJDGKHELQvjZqQ== | |
| aes-256-cfb8 | 1k1yiacKd98o6mj9e4XQmYHTVMKzNCt+tpLZWdnYo3GXQW1R+jdFJc5/8A== | |
| aes-256-ctr | 1ktyGwyrPTtkgyEyM7E0vQLKxTEZHxPxUe5qC3Z5g5i4uVLf/iFZqWMTPA== | |
| aes-256-ecb Legacy | oV3RJ8KJkJ8RE7zaMmiC3FGyw0egBuzK22+UB+wjL1x957WvwKfkmU0DQekRltBh | |
| aes-256-gcm | no result | |
| aes-256-ocb | no result | |
| aes-256-ofb | 1ktyGwyrPTtkgyEyM7E0veMveBwf24cCnL4wm6FGkvqIJsJlhyZEOlt1Ow== | |
| aes-256-xts | f5eVcJyT+UmSHL+ofoaYWABwFrKp62H6idKb0pdKw+vAnBxMpZyHb8MbJA== | |
| aes256 | oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeW | aes-256-cbc, aes-256-cbc-hmac-sha1, aes-256-cbc-hmac-sha256 |
| aes256-wrap | no result | |
| id-aes256-ccm | no result | |
| id-aes256-gcm | no result | |
| id-aes256-wrap | no result | |
| id-aes256-wrap-pad | tk28ra1iLSVR4bLEB5vUiHgPkrA4Sxc4iXlhTK/5xgwnwK9SS39Ysij8omADCyGcqoxCQXdsRWQ= |
aes-256-xts test values
Results for common test strings with the secret my secret (UTF-8, no line break, zero IV), exactly as the tool and PHP's openssl_encrypt give them. Use them to check your own implementation.
| Text | aes-256-xts (Base64) |
|---|---|
| empty string | no result |
a | no result |
hello world | no result |
0123456789abcdef | dIaNRmDgOodAyZTDXfqkVQ== |
The quick brown fox jumps over the lazy dog | f5eVcJyT+UmSHL+ofoaYWABwFrKp62H6idKb0pdKw+vAnBxMpZyHb8MbJA== |
Questions about aes-256-xts
Can aes-256-xts be decrypted without the secret?
No. Without the secret there is no shortcut. A short or common secret can be guessed, though, because the tool uses it directly as the key.
Why does my aes-256-xts code give a different result?
Almost always because of the key or the IV: the tool pads your secret with zero bytes instead of hashing it and uses a zero IV. Also check Base64 vs hex, padding, and spaces or line breaks the tool trims.
Is AES-256 secure?
AES-256 itself has no practical attack and has the largest security margin of the three key sizes, also against future quantum computers. What makes a setup weak is a guessable key, a reused IV or missing authentication.
How long should my secret be?
Exactly 64 bytes (512 bits) fills the key; anything after that is ignored. For real security a random key is better than a typed word.