1. ## Block cipher(cryptography)

The block cipher $\left(\mathcal{P},\mathcal{C},\mathcal{K},\mathcal {E},\mathcal{D}\right)$ is defined as follows. The alphabet is {0,1}, block length is 3 and the key space $\mathcal{K}$ is $\mathbb{Z}_8$. Given a key $n\in\mathbb{Z}_8$ and a plaintext $p$, let $p'$ be $p$ written as a decimal number. We define $E_n(p)$ to be $p'+nmod8$ written as a 3-digit binary number (possibly with initial zeros), and we define $D_n(p)$ in exactly the same way. The functions $E_n$ and $D_n$ are the encryption and decryption functions respectively of the cryptosystem.

(a) Find $E_5(110),E_2(001),E_0(101).$
(b) Given an excryption key $n$, find a corresponding decryption key

Any help would be greatly appreciated, thanks=)

2. For part (a), it looks as though you simply add $n$ to the plaintext, and then mod out $8$. Example:

$E_{3}(010_{2})=2+3\;\text{mod}\;8=5\;\text{mod}\;8 =101_{2}.$

Here I've used the subscript $2$ to indicate that I'm writing the number base $2$.

Does that make sense?

For part (b), you have to find a way to invert the operation in part (a). So, taking my example, we had better find that

$D_{n}(101_{2})=010_{2},$ using some integer $n$. How do you undo addition? How do you undo addition modulo an integer?

3. Hi Ackbeet, thanks a lot for your post, I understand now =)

4. You're welcome. Have a good one!