aes-256-ctr encrypt & decrypt online

Encrypt or decrypt text with aes-256-ctr and a secret. Same result as PHP's openssl_encrypt, and nothing leaves your browser.

Padded with zero bytes or cut to 32 bytes. No IV, PHP uses zero bytes.
Runs in your browser
What the tool did

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 hello world and the secret my secret until you type above.

Key · 32 bytes 9 from your secret, 23 zero bytes added
6d79207365637265740000000000000000000000000000000000000000000000
6d79207365637265740000000000000000000000000000000000000000000000
IV · 16 bytes none given, so zero bytes
00000000000000000000000000000000
00000000000000000000000000000000
Text in UTF-8 11 bytes, no padding needed
68656c6c6f20776f726c64
Encrypted · 11 bytes
ea467b5712fe23377dcf27
ea467b5712fe23377dcf27
As Base64 what the tool shows
6kZ7VxL+Izd9zyc=

from your inputzero bytesciphertext

In short

What is aes-256-ctr?

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-CTR uses a 256-bit key (14 rounds) in Counter mode: an encrypted counter forms a keystream that is XORed with the text.

Strong cipherAES (Rijndael): No practical attack on the cipher itself is known.

How your secret becomes the key

AES-256-CTR needs exactly 32 bytes (256 bits) of key. The tool takes your secret as UTF-8 bytes and pads it with zero bytes to 32 bytes, or cuts it after 32 bytes.

Where you meet AES
  • HTTPS and TLS
  • Wi-Fi (WPA2, WPA3)
  • Disk encryption: BitLocker, FileVault, LUKS
  • VPNs, ZIP and 7-Zip archives, password managers
Honest answer

Is it safe to use?

The cipher: strong cipher

AES. No practical attack on the cipher itself is known.

This setup: for compatibility

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?

Counter

How CTR mode works

CTR encrypts a counter: the IV, then IV + 1, IV + 2 and so on (OpenSSL counts with the whole 16-byte IV as one big-endian number). The results are XORed with the text. Every block can be computed independently, which makes CTR fast and parallel. GCM is CTR plus an authentication tag.

No padding: output length = input length. Like OFB, the same key and IV always give the same keystream, so a fixed IV must never be reused for different texts in real systems.

Use it in code

The same result in your code

Every snippet prints 6kZ7VxL+Izd9zyc= for the text hello world 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.

PHP
$key = hex2bin("6d79207365637265740000000000000000000000000000000000000000000000"); // "my secret" padded with zero bytes to 32 bytes
$iv  = hex2bin("00000000000000000000000000000000"); // no IV given: 16 zero bytes
echo openssl_encrypt("hello world", "aes-256-ctr", $key, 0, $iv);

Shortest form, same result: openssl_encrypt("hello world", "aes-256-ctr", "my secret"). PHP pads the secret itself but warns about the empty IV.

Python
# pip install cryptography
import base64
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes

key = bytes.fromhex("6d79207365637265740000000000000000000000000000000000000000000000")  # "my secret" padded with zero bytes to 32 bytes
iv = bytes(16)  # no IV given: 16 zero bytes
data = "hello world".encode()
enc = Cipher(algorithms.AES(key), modes.CTR(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.

Node.js
import { createCipheriv } from 'node:crypto';

const key = Buffer.from("6d79207365637265740000000000000000000000000000000000000000000000", 'hex'); // "my secret" padded with zero bytes to 32 bytes
const iv = Buffer.alloc(16); // no IV given: 16 zero bytes
const c = createCipheriv("aes-256-ctr", key, iv);
console.log(Buffer.concat([c.update("hello world", 'utf8'), c.final()]).toString('base64'));
Java
import javax.crypto.Cipher;
import javax.crypto.spec.*;
import java.util.Base64;
import java.util.HexFormat;

public class Encrypt {
  public static void main(String[] args) throws Exception {
    byte[] key = HexFormat.of().parseHex("6d79207365637265740000000000000000000000000000000000000000000000"); // "my secret" padded with zero bytes to 32 bytes
    byte[] iv = new byte[16]; // no IV given: 16 zero bytes
    Cipher c = Cipher.getInstance("AES/CTR/NoPadding");
    c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"), new IvParameterSpec(iv));
    System.out.println(Base64.getEncoder().encodeToString(c.doFinal("hello world".getBytes("UTF-8"))));
  }
}

Java 17 or newer (HexFormat). Java's PKCS5Padding is the same as PKCS#7.

Go
package main

import (
	"crypto/aes"
	"crypto/cipher"
	"encoding/base64"
	"encoding/hex"
	"fmt"
)

func main() {
	key, _ := hex.DecodeString("6d79207365637265740000000000000000000000000000000000000000000000") // "my secret" padded with zero bytes to 32 bytes
	block, _ := aes.NewCipher(key)
	iv := make([]byte, block.BlockSize()) // no IV given: zero bytes
	data := []byte("hello world")
	out := make([]byte, len(data))
	cipher.NewCTR(block, iv).XORKeyStream(out, data)
	fmt.Println(base64.StdEncoding.EncodeToString(out))
}
Command line
printf '%s' 'hello world' | openssl enc -aes-256-ctr -K 6d79207365637265740000000000000000000000000000000000000000000000 -iv 00000000000000000000000000000000 -a -A

printf instead of echo: echo adds a line break, which changes the result. -K and -iv take hex; with -k or -pass, openssl derives a different key from a password.

Common mistakes

Why your aes-256-ctr result doesn't match

You hashed the secret first

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.

Your code uses a random IV

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.

Hex instead of Base64

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.

Same start as CFB, OFB and CTR

With a zero IV, CFB, OFB and CTR all begin by encrypting the IV, so the first block of output is identical in all three. They only differ from the second block on.

Output is as long as the input

This mode needs no padding: 11 bytes in, 11 bytes out. If your library adds PKCS#7 padding or expects whole blocks, it is configured for CBC or ECB.

Same secret, same keystream

Without a nonce, every text encrypted with the same secret uses the same keystream. XOR two ciphertexts and the keystream cancels out, leaving the XOR of the two texts. That's how WEP was broken.

Spaces and line breaks

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.

Your secret is longer than the key

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.

openssl enc with -k or -pass

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.

CryptoJS with a passphrase

CryptoJS.AES.encrypt(text, "password") treats a string as a passphrase and uses the same salted OpenSSL format (U2FsdGVkX1…). To match this tool, pass the key and IV as WordArrays with CryptoJS.enc.Hex.parse().

Which cipher was it?

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-ctr.

Nothing is sent anywhere. Wrong secrets give no readable text.
Compare

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-ctr. 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.

CipherResult (Base64)Same as
aes-256-cbc oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeWaes-256-cbc-hmac-sha1, aes-256-cbc-hmac-sha256, aes256
aes-256-cbc-hmac-sha1 oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeWaes-256-cbc, aes-256-cbc-hmac-sha256, aes256
aes-256-cbc-hmac-sha256 oV3RJ8KJkJ8RE7zaMmiC3IvqaRrBXzj1Yz1LI+TEjH66KfwmN6R6qHzKZHVs2zeWaes-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 LegacyoV3RJ8KJkJ8RE7zaMmiC3FGyw0egBuzK22+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+TEjH66KfwmN6R6qHzKZHVs2zeWaes-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=
Test values

aes-256-ctr 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.

Textaes-256-ctr (Base64)
empty string
a4w==
hello world6kZ7VxL+Izd9zyc=
0123456789abcdefshIlCEnrYm83miIiP6I/+w==
The quick brown fox jumps over the lazy dog1ktyGwyrPTtkgyEyM7E0vQLKxTEZHxPxUe5qC3Z5g5i4uVLf/iFZqWMTPA==
FAQ

Questions about aes-256-ctr

Can aes-256-ctr 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-ctr 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.

Why is the aes-256-ctr output shorter than with CBC?

CTR mode needs no padding: the ciphertext has exactly as many bytes as the text, while CBC rounds up to whole blocks.

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 32 bytes (256 bits) fills the key; anything after that is ignored. For real security a random key is better than a typed word.

Good to know

Before you rely on it

Searches the list of pages on this site. What you type stays in your browser.