1
$\begingroup$

Suppose I have the message $m_1 = \sf{i\ like\ dogs}$.

Suppose its one-time pad encryption with key $k$ is a given hexadecimal string of 22 characters.

How would I encrypt a message $m_2 = \sf{i\ like\ cats}$ with the same key $k$?


I was given a similar question (but with different messages). Firstly I observed that the hexadecimal ciphertext had twice the character count than the message, so I thought each message character was mapped to a hexadecimal string of 2 characters.

My problem is that I don't know how would the $\oplus$ of the one-time pad work in this situation (as the message is not binary), so I couldn't guess the key. Any idea on how this should work?

$\endgroup$
1
  • 1
    $\begingroup$ I think $\oplus$ should be the same in the hexadecimal case. Two-character hex or a byte is just different ways to represent an 8-bit sequence. The $\oplus$ in one byte is similar to $\oplus$ the $\{0,1,2,...,F\}$ considering that each hex character represents 4-bit subsequence. $\endgroup$ Commented Jul 11, 2018 at 4:39

1 Answer 1

0
$\begingroup$

It's fairly simple. 1st byte of $k$ in pseudo code is:-toAscii("i") XOR toBinary(1st hex pair). ASCII code of "i" = 105 as an example. Then repeat for the remaining bytes to obtain all of $k$.

See ASCII and Hexadecimal for reference.

$\endgroup$
1
  • $\begingroup$ I realized I could cast both hexadecimal and ascii to integers, do the bitwise-xor between them and find the key this way $\endgroup$ Commented Jul 11, 2018 at 16:43

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.