0
$\begingroup$

For practicing purposes I obtained some cipher and an OTP key. Now my task is to decrypt the cipher using this key.

Both files are .bin files and when I open them with TextEdit there are a huge amount of "strange" symbols (which is obv., since its a cipher text).

But my questions is: How can I get the plaintext using the key?

$\endgroup$
  • 7
    $\begingroup$ Write a program, that reads in both files and XORs the bytes at the same positions? $\endgroup$ – SEJPM May 4 '17 at 17:04
  • $\begingroup$ You understand what a OTP is and how they work? It should then follow how to decrypt. $\endgroup$ – Paul Uszak May 4 '17 at 20:27
  • $\begingroup$ Although we usually call it cipher-text, it's actually binary. There are many mistakes by programmers on stackoverflow that treat the ciphertext (or the key for that matter) as text. This may in the worst case lead to missing data (and usually, therefore, the ability to decrypt). $\endgroup$ – Maarten - reinstate Monica May 4 '17 at 20:28
  • $\begingroup$ @MaartenBodewes that really depends on how the programmer implements it, the last one time pad program I wrote was for text only and so I just used int, char, and modulo 26 like right off the wikipedia example. $\endgroup$ – daniel May 5 '17 at 7:01
  • $\begingroup$ Hmm, yeah, should have said it is usually binary, especially if XOR is used - an operation on binary input. For modern ciphers it is certainly binary most of the time. $\endgroup$ – Maarten - reinstate Monica May 5 '17 at 7:46
3
$\begingroup$

The "strange" symbols are caused by TextEdit trying to interpret raw binary data as readable characters. Both files You have are just streams of zeroes and ones. When you run a XOR operation on each bit of cipher with corresponding bit of key the result should be the hidden message that should be readable by TextEdit. I usually do things like that by writing a script in Python.

$\endgroup$
  • $\begingroup$ Thanks for your answer, can you explain me how I can make the file readable? So I can see actually the zeros and ones? The data format is .bin $\endgroup$ – Marc May 4 '17 at 21:18
  • $\begingroup$ Not exactly zeroes and ones, but You can take a look with HexEdit it will take each eight bits and display them as two digit hexadecimal value. for example 00000000b = 0x00, 00001111b = 0x0F and 11111111b = 0xFF (the "b" means that it's binary notation and "0x" means that it's hexadecimal notation) Python works very well with this hexadecimal notation. $\endgroup$ – Filip Franik May 4 '17 at 21:26
  • $\begingroup$ You can also use the windows calculator set to "programmer" mode with "hex" setting to manually XOR the values you read from HexEdit. $\endgroup$ – Filip Franik May 4 '17 at 21:33
  • $\begingroup$ In linux use: $ xxd -b <filename> $\endgroup$ – puzzlepalace May 4 '17 at 21:50

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