i have a problem that goes: Suppose you are told that the one time pad encryption of the message "attack at dawn" is 09e1c5f70a65ac519458e7e53f36 (the plain text letters are encoded as 8-bit ASCII and the given ciphertext is written in hex) What would be the OTP Encryption of the message "attack at dusk" under the same OTP key?

I know this question is asked a lot, but I already tried with this (all by hand and some calculators).

ciphertxt:00001001 11100001 11000101 11110111 00001010 01100101 10101100 01010001 10010100 01011000 11100111 11100101 00111111 00110110

message: 01100001 01110100 01110100 01100001 01100011 01101011 00100000 01100001 01110100 00100000 01100100 01100001 01110111 01101110

key: 110100010010101101100011001011001101001000011101000110000110000111000000111100010000011100001000100100001011000

obj message: 01100001 01110100 01110100 01100001 01100011 01101011 00100000 01100001 01110100 00100000 01100100 01110101 01110011 01101011 00001101 00001010

o.msg xor key: 1100001011101000001110011110100110100101111110101001001011011111111100000010000100001000000110111110000111011110100010101010010

to hex: c2 e8 39 e9 a5 fa 92 df f0 21 08 1b e1 de 8a 52

I don't know what am I doing wrong but that's not the correct answer. Thanks

  • $\begingroup$ just xor the last three bytes with the xor of "awn" and "usk" and you're done. It's a lot less work than you think. Use that $(p_1 \oplus k) \oplus (p_1 \oplus p_2) = p_2 \oplus k$. $\endgroup$ – Henno Brandsma Aug 22 '19 at 19:28

How did you get the key from message & cipher text seems that step is flawed. The general approach seems correct.

Also most people would write a tiny bit of code in their programming language of choice rather than do this by hand. If you are not comfortable writing code, I strongly urge you to pick up a tutorial. Even classic cryptography is far easier with some basic programming skills.

| improve this answer | |
  • $\begingroup$ Yes, I am a programmer, but I have never use this type of conversions in Java. I got the key doing an XOR in binary with the message and the cipher text, but I have no idea why this is incorrect. Thanks! $\endgroup$ – Mel J Aug 22 '19 at 17:01
  • $\begingroup$ notice the first message bit is 0 and the first ciphertext bit is 0, but your first key bit came out 1. I suspect you may have got things mangled because your last key byte seems to match the first from message and cipher. $\endgroup$ – Meir Maor Aug 22 '19 at 17:04
  • $\begingroup$ Thanks, I'm going to check again what went wrong $\endgroup$ – Mel J Aug 22 '19 at 17:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.