Tool to decrypt/encrypt with XOR cipher (eXclusive OR), a moder cryptographic method that consists in encrypting a binary message with a repeated key using a XOR multiplication.

XOR Cipher - dCode

Tag(s) : Modern Cryptography

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

XOR encryption is a symmetrical encryption/decryption method based on the use of the logical/binary operator `XOR` (also called Exclusive Or, symbolized by `⊕`). The XOR cipher uses as operands the plain text and the key (previously encoded in binary/bit string).

The XOR operation takes 2 bits as input and returns one bit as output according to the following truth table: if the two bits are different, the result is 1, otherwise the result is 0.

XOR is applied on binary data, if the message is text, encoding (conversion to ASCII or Unicode) must be performed.

__Example:__ Encrypt the plain message `1001` with the key `10`

Take the first bit of the plain text and the first bit of the key and multiply then using XOR operation to get the ciphered bit.

__Example:__ `1 ⊕ 1 = 0`

The operation is repeated with the second bit of the plaintext and the second bit of the key. At the end of the key, loop back to the first bit.

__Example:__

Plain message | 1001 | Key (repeated) | 1010 | Encrypted message | 0011 |

XOR Decryption (UnXOR/DeXOR) is identical to encryption because the XOR operation is symmetrical (reverse XOR = XOR).

__Example:__ `1001 ⊕ 1010 = 0011` and `0011 ⊕ 1010 = 1001`

dCode manages the conversion automatically, but by default the ASCII encoding table for classic characters (letters of the alphabet or numbers) allows each character to be coded by a number between 0 and 127, which is then converted to base 2 (binary). For accented or less common characters (symbols, emojis, etc.) dCode uses Unicode.

The truth table of the 2-parameter XOR logic function is:

A | B | A xor B |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

A xored message (XOR encrypted message) has no particularities, this makes it hard to detect.

It can be presented under binary form but also as ascii text.

Data in the form of a stream is well suited to XOR encoding.

The XOR operation is one of the basics of logical computing. Computer processors can perform this type of calculation immediately, billions of times per second, which is therefore useful if computing resources are limited.

The XOR operation has the advantage of being reversible and above all symmetrical by applying the same algorithm, which further simplifies the calculations.

XOR encryption provides some cryptographic security when the key is as large as the original message, otherwise XOR is vulnerable to known-plaintext attacks.

Xor decryption without knowing the key is hard. It is possible to find all or a part of the key by knowing a part of the plain text. Else, there are no practical methods other than trying all the keys.

XOR is compatible with the principle of autoclave cipher.

dCode retains ownership of the "XOR Cipher" source code. Except explicit open source licence (indicated Creative Commons / free), the "XOR Cipher" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "XOR Cipher" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "XOR Cipher" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!

Reminder : dCode is free to use.

The copy-paste of the page "XOR Cipher" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!

Exporting results as a .csv or .txt file is free by clicking on the *export* icon

Cite as source (bibliography):

*XOR Cipher* on dCode.fr [online website], retrieved on 2024-09-10,

- XOR Decoder
- XOR Calculator
- What is the XOR cipher? (Definition)
- How to encrypt using XOR cipher?
- How to decrypt XOR cipher?
- How to convert a text into binary?
- What is the truth table for XOR?
- How to recognize XOR ciphertext?
- What are the pros and cons of XOR?
- How to decipher XOR without the key?
- What are the variants of the XOR cipher?

xor,or,exclusive,binary,bin,xored,unxor

https://www.dcode.fr/xor-cipher

© 2024 dCode — El 'kit de herramientas' definitivo para resolver todos los juegos/acertijos/geocaching/CTF.

Feedback