One-Time Pad XOR Tool
Enter a message and key, choose encrypt or decrypt, and XOR them together.
Result
How it is calculated
The tool works on bytes. To encrypt it takes each byte of the message and combines it with the matching byte of the key using XOR: Ci = Pi ⊕ Ki mod len. If the key is shorter than the message it is repeated. Each result byte is written as two uppercase hex digits. To decrypt, paste the hex (spaces are ignored; it needs an even number of hex digits), and the tool XORs each byte with the same key and returns the text. Because XOR undoes itself, the same key restores the original. Characters outside plain ASCII use several bytes, so the byte count can exceed the character count. A wrong key on decrypt gives garbage or unprintable characters, and an empty message or key gives no result.
Worked example
Encrypt HELLO with the key XMCKL, which has the same length as the message. In hex the letters H E L L O are 48 45 4C 4C 4F and the key letters X M C K L are 58 4D 43 4B 4C. XOR pair by pair: 48 ⊕ 58 = 10, 45 ⊕ 4D = 08, 4C ⊕ 43 = 0F, 4C ⊕ 4B = 07, 4F ⊕ 4C = 03. The output is 10080F0703 and the byte count is 5. Switching to decrypt with the same key and this hex returns HELLO.
Common mistakes
- Believing the output is unbreakable. It is only a true one-time pad if the key is random, as long as the message and never used again; a short, repeated or guessable key like a word can be broken.
- Reusing one key for two messages. XOR-ing the two ciphertexts cancels the key and exposes the relation between the plaintexts.
- Pasting ordinary text in decrypt mode. Decryption expects hex digits only; plain words or an odd number of digits give no result.
- Using a different key or changing a character when decrypting. A single wrong key byte changes the matching output byte, so the text comes out garbled.
- Counting characters instead of bytes. An accented letter such as ü takes two bytes, so the byte length and hex output are longer than you might expect.
About this calculator
The one-time pad, formalized by Gilbert Vernam, achieves theoretically perfect secrecy by combining each plaintext byte with a key byte of equal length using XOR — a reversible bitwise operation where applying the same key twice returns the original data (P ⊕ K = C, then C ⊕ K = P). Perfect secrecy only holds if the key is truly random, exactly as long as the message, and never reused; in practice, the same math with a short repeating key (as this tool does) produces a simple, breakable stream cipher rather than a true unbreakable pad.
This tool XORs a message against a key — repeating the key to match the message length — to encrypt text into hex or decrypt hex back into text. Cryptography students use it to see XOR-based encryption mechanics firsthand, and CTF players and security learners use it to quickly encode or decode XOR-cipher challenges by hand.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
One handy quirk when encrypting: wherever a message byte equals the matching key byte, the output byte is 00, because anything XORed with itself is zero. Long runs of 00 in the hex therefore mean the key is echoing the plaintext at those spots, which is a good sign the key is too short or too guessable. Do you use this for coursework or puzzle challenges, and what kind of key lengths do you try?