des encrypt & decrypt online
LegacyEncrypt or decrypt text with des 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 hello world and the secret my secret until you type above.
- Key · 8 bytes 8 from your secret, 1 cut off
- 6d79207365637265
6d79207365637265 - IV · 8 bytes none given, so zero bytes
- 0000000000000000
0000000000000000 - Text in UTF-8 11 bytes of text + 5 bytes PKCS#7 padding (value
05) = 16 bytes, 2 blocks of 8 - 68656c6c6f20776f726c640505050505
- Encrypted · 16 bytes
- 44d594dd79de287ee4f60c99a7e3798a
44d594dd79de287ee4f60c99a7e3798a - As Base64 what the tool shows
RNWU3XneKH7k9gyZp+N5ig==
- Your secret is longer than the key. The bytes after the key length are ignored.
- DES ignores the lowest bit of each key byte (parity bit).
from your inputzero bytespaddingciphertext
What is des?
des is another name for des-cbc in OpenSSL and PHP: same key, same mode, same result. DES is the US standard cipher from 1977. Its 56-bit key is far too short: in 1999 a public effort found a DES key in 22 hours. It is only used to read or match old data. It uses a 64-bit key (16 rounds) in Cipher Block Chaining mode: each 8-byte block is mixed with the previous encrypted block before it is encrypted.
How your secret becomes the key
DES-CBC needs exactly 8 bytes (64 bits) of key. The tool takes your secret as UTF-8 bytes and pads it with zero bytes to 8 bytes, or cuts it after 8 bytes. DES only uses 7 bits of each key byte: the lowest bit is a parity bit and ignored, so 56 bits count.
- Old banking and payment systems
- Legacy file formats and protocols
- Teaching (Feistel networks)
Is it safe to use?
DES. Can be attacked in practice. Only use it to read or match old data.
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 CBC mode works
CBC splits the text into 8-byte blocks. Before a block is encrypted, it is XORed with the previous encrypted block; the first block is XORed with the IV. So every block depends on all blocks before it.
The last block is filled up with PKCS#7 padding: if 5 bytes are missing, five bytes 05 are added. A text that fills its last block exactly gets a whole extra block of padding. That is why the output is always a multiple of 8 bytes and at least one byte longer than the input.
With a random IV, the same text gives a different result each time. This tool uses no IV (zero bytes), so the same text and secret always give the same result, and the first block is identical to ECB.
Really calculated: each square is one 8-byte block, coloured by the first byte of its ciphertext. With ECB, equal blocks stay equal and the heart shows through. With CBC, every block depends on the one before.
The same result in your code
Every snippet prints RNWU3XneKH7k9gyZp+N5ig== 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.
$key = hex2bin("6d79207365637265"); // "my secret" cut to 8 bytes $iv = hex2bin("0000000000000000"); // no IV given: 8 zero bytes echo openssl_encrypt("hello world", "des", $key, 0, $iv);
Shortest form, same result: openssl_encrypt("hello world", "des", "my secret"). PHP pads the secret itself but warns about the empty IV. On OpenSSL 3, PHP needs the legacy provider enabled in openssl.cnf.
# pip install cryptography import base64 from cryptography.hazmat.primitives.ciphers import Cipher, modes from cryptography.hazmat.decrepit.ciphers import algorithms from cryptography.hazmat.primitives import padding key = bytes.fromhex("6d79207365637265") # "my secret" cut to 8 bytes iv = bytes(8) # no IV given: 8 zero bytes data = "hello world".encode() padder = padding.PKCS7(64).padder() data = padder.update(data) + padder.finalize() enc = Cipher(algorithms.TripleDES(key), modes.CBC(iv)).encryptor() print(base64.b64encode(enc.update(data) + enc.finalize()).decode())
Python has no DES in the standard library; the cryptography package keeps it in its "decrepit" module for old data.
import { createCipheriv } from 'node:crypto'; const key = Buffer.from("6d79207365637265", 'hex'); // "my secret" cut to 8 bytes const iv = Buffer.alloc(8); // no IV given: 8 zero bytes const c = createCipheriv("des-cbc", key, iv); console.log(Buffer.concat([c.update("hello world", 'utf8'), c.final()]).toString('base64'));
Run with node --openssl-legacy-provider: OpenSSL 3 hides this cipher by default.
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("6d79207365637265"); // "my secret" cut to 8 bytes byte[] iv = new byte[8]; // no IV given: 8 zero bytes Cipher c = Cipher.getInstance("DES/CBC/PKCS5Padding"); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "DES"), 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.
package main import ( "bytes" "crypto/cipher" "crypto/des" "encoding/base64" "encoding/hex" "fmt" ) func main() { key, _ := hex.DecodeString("6d79207365637265") // "my secret" cut to 8 bytes block, _ := des.NewCipher(key) iv := make([]byte, block.BlockSize()) // no IV given: zero bytes data := []byte("hello world") n := block.BlockSize() - len(data)%block.BlockSize() // PKCS#7 padding data = append(data, bytes.Repeat([]byte{byte(n)}, n)...) out := make([]byte, len(data)) cipher.NewCBCEncrypter(block, iv).CryptBlocks(out, data) fmt.Println(base64.StdEncoding.EncodeToString(out)) }
printf '%s' 'hello world' | openssl enc -des-cbc -K 6d79207365637265 -iv 0000000000000000 -provider legacy -provider default -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.
Why your des result doesn't match
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.
The tool pads with PKCS#7 (OpenSSL's default). Some libraries pad with zeros or not at all. A text of exactly one block still gets a full block of padding (10 10 … 10 for 16-byte blocks).
With a zero IV, the first CBC block is exactly the ECB block, because XOR with zeros changes nothing. Texts up to one block long (15 bytes plus padding) give the same result in CBC and ECB. From the second block on they differ, see the family comparison.
DES ignores the lowest bit of every key byte. Secrets that differ only there, such as a and ` (0x61 and 0x60), give identical results.
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.
OpenSSL 3 moved this cipher to the legacy provider. Node.js, PHP, Python and the openssl command line built on OpenSSL 3 report it as unsupported until the legacy provider is loaded (node --openssl-legacy-provider, openssl enc -provider legacy -provider default).
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 des.
Every DES and Triple DES variant, same input
The text The quick brown fox jumps over the lazy dog (43 bytes) with the secret my secret in all 24 DES and Triple DES ciphers. The last column lists names that give the same result: aliases, and modes that agree for this input. Highlighted: the same start as des. Watch how CBC and ECB share the first block, and CFB, OFB and CTR the first 8 bytes. Type a text and a secret in the tool above to use yours.
| Cipher | Result (Base64) | Same as |
|---|---|---|
| des Legacy | 0bA3hT4PqaA6P4grYRvzUBUAGvpdcwiTCXJTZlMO1+yv2OEYGhgYmE4+DlE3oGJL | des-cbc |
| des-cbc Legacy | 0bA3hT4PqaA6P4grYRvzUBUAGvpdcwiTCXJTZlMO1+yv2OEYGhgYmE4+DlE3oGJL | des |
| des-cfb Legacy | 02Hv2U2qFHmk1YsGGuzyjbaEGYxerKIHMbyX+fDkXEjt3j/QeCcjB2AFzQ== | |
| des-cfb1 Legacy | xji1RZATdSX7BBIU+v0mKIdnN4gC0wIQlbrjgnbVDSlQTpWy+HM/U/Af7w== | |
| des-cfb8 Legacy | 0zQRFiLI4IpoX3zhdxKoP1eOiGFjXyMl8M7XrqDRNqK5cDv9nyiZj08bsg== | |
| des-ecb Legacy | 0bA3hT4PqaBGCTN+NK8kz6arEwlsenPMuftXeVy706LosWwgGNS/kAV39nzVgegs | |
| des-ede Legacy | VQAgAnCgtiTPsdxTJ6HFdLP0N7BqwPngn6rvJ26LipRlVJEqW+BoMeqmW6buZpdm | des-ede-ecb |
| des-ede-cbc Legacy | VQAgAnCgtiQzlY21xKZdjPmLpLIRLR+NBtr8noYcRo4YHOZ3JvH+qsX5linqoR6M | |
| des-ede-cfb Legacy | arrxSsoIGF9JBiphmNZbdpVkVcXVmRlYKVHUIEF3A4KNYcxtupVf8IxAJw== | |
| des-ede-ecb Legacy | VQAgAnCgtiTPsdxTJ6HFdLP0N7BqwPngn6rvJ26LipRlVJEqW+BoMeqmW6buZpdm | des-ede |
| des-ede-ofb Legacy | arrxSsoIGF9G9FnyO+6bgMQ9K0BQfn+xQ7bkCGh9igmU4kb3GHGDLTting== | |
| des-ede3 Legacy | WmVOV7KruhMo6OpASvcZz/SJTz4kbwgMaqYmUiKaPjOiOfE8YxysuP5gu0PUGvCY | des-ede3-ecb |
| des-ede3-cbc Legacy | WmVOV7KruhOCm6HCT/9l8EejwpsvM/D2BjGsQB53EUCdyIiabE03/wGUkzjbJBPR | des3 |
| des-ede3-cfb Legacy | Gyevnv0MdXSu2Z7GMEliPovFDV3FR3wbdd16B20q8AiP2jDwxtZL7dbgTw== | |
| des-ede3-cfb1 Legacy | V0b4gFcFbO+mMnZLTEwYAicPGcFdW8l16fjwjKiGmFFXoLpdlXOUJzkHaw== | |
| des-ede3-cfb8 Legacy | G/GpkCVSSBHihawied5fcV1jW05WwgtRZ1xaA0Env5OeC24hAkhCsjT+pQ== | |
| des-ede3-ecb Legacy | WmVOV7KruhMo6OpASvcZz/SJTz4kbwgMaqYmUiKaPjOiOfE8YxysuP5gu0PUGvCY | des-ede3 |
| des-ede3-ofb Legacy | Gyevnv0MdXSuY5+gbTgo54KoOmCaKYqiytdUNhx+FLtZGzTdD66v15Qihg== | |
| des-ofb Legacy | 02Hv2U2qFHmJWYhQyinFdiE6oI9dZjxmC3CZiJqx/NaMtHHrGCSl+WPg2A== | |
| des3 Legacy | WmVOV7KruhOCm6HCT/9l8EejwpsvM/D2BjGsQB53EUCdyIiabE03/wGUkzjbJBPR | des-ede3-cbc |
| des3-wrap Legacy | different every time (random IV) | |
| desx Legacy | nskG7SWseL+R4S+F5ZfWi36BUvVqJn4qFQpzjlrXkQ+e4WMfUL2tvxntpHuJ7Uu/ | desx-cbc |
| desx-cbc Legacy | nskG7SWseL+R4S+F5ZfWi36BUvVqJn4qFQpzjlrXkQ+e4WMfUL2tvxntpHuJ7Uu/ | desx |
| id-smime-alg-cms3deswrap Legacy | different every time (random IV) |
des 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 | des (Base64) |
|---|---|
| empty string | ceStRD+TJFQ= |
a | W9LcfihI8Zs= |
hello world | RNWU3XneKH7k9gyZp+N5ig== |
0123456789abcdef | hO4DHULBzwYI6NtgHb6hey22qq06iKnp |
The quick brown fox jumps over the lazy dog | 0bA3hT4PqaA6P4grYRvzUBUAGvpdcwiTCXJTZlMO1+yv2OEYGhgYmE4+DlE3oGJL |
Questions about des
Is des the same as des-cbc?
Yes, in this tool and in PHP on OpenSSL 1.1.1 they give exactly the same result. des is just another name, so you can decrypt with either.
Can des be decrypted without the secret?
No. Without the secret there is no shortcut, except that DES's weak key lets a determined attacker try every key. A short or common secret can be guessed, though, because the tool uses it directly as the key.
Why does my des 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 do des-cbc and des-ecb give the same result?
Only for short texts. With a zero IV, the first CBC block equals the ECB block. From the second block on, CBC mixes in the previous block and the results differ.
Is DES secure?
No. DES can be attacked in practice. Use it only to read or match old data.
How long should my secret be?
Exactly 8 bytes (64 bits) fills the key; anything after that is ignored. For real security a random key is better than a typed word.
Before you rely on it
Data Encryption Standard (DES): Understanding the Limitations
Encryption is a fundamental tool for protecting sensitive information, and one of the most widely used encryption algorithms is the Data Encryption Standard (DES). However, it's important to be aware of the limitations of the encryption methods. In this article, we will delve into the details of DES encryption, including its history, how it works, and its common use cases, as well as its limitations and the reasons why it's no longer considered a secure encryption method. We will also provide a guide on how to use our DES encryption/decryption tool and the scenarios where it can be used.
A Brief History of DES
DES was developed in the 1970s by IBM and was officially adopted as a standard by the National Institute of Standards and Technology (NIST) in 1977. It was the first widely-used encryption algorithm and it was widely used in the financial industry and the US Government.
How DES Works
DES is a symmetric-key block cipher that encrypts data in 64-bit blocks. It uses a fixed-length key of 56 bits, making it relatively easy to break using brute-force methods. The algorithm uses a Feistel network, which divides the input data into two halves, processes them separately, and then combines them to produce the output.
Limitations of DES
One of the main limitations of DES is its key size. With only 56 bits, it is relatively easy to break using brute-force methods. This was already considered a limitation at the time of its adoption, and the use of DES was officially phased out in 2005 by NIST. Moreover, it is not recommended to use it for new systems, as there are more secure encryption methods available such as AES.
Use Cases for DES
Despite its limitations, DES is still used in some legacy systems, and it can be used in scenarios where the data is not considered highly sensitive or where the system is not connected to the internet. It's also used for backwards compatibility, for example, if a system was encrypted with DES and the key is lost, it may be the only way to decrypt the data.
Using our DES Encryption/Decryption Tool
If you're working with legacy systems, or you need to decrypt data that was encrypted with DES, our tool can be useful. With just one mouse click, you can des encrypt or des decrypt any string. However, it's important to keep in mind that DES is no longer considered secure and it is not recommended to use it for new systems.
In conclusion, DES is an encryption algorithm that was widely used in the past, but it's no longer considered secure and it is not recommended to use it for new systems. It's important to be aware of the limitations of the encryption methods and use the most suitable and secure algorithm for your specific use case. In situations where data is not highly sensitive, or where the system is not connected to the internet, or for backwards compatibility, DES can be used.