# Re: Simple cipher program help

Date: 04/28/03

```Date: Mon, 28 Apr 2003 12:51:51 -0400

```

"Paul" <luap.h@bt_removethis_internet.com> wrote in message
news:b8j6ks\$jii\$1@hercules.btinternet.com...
> I'm trying to write a program to take 64bits of plaintext in, using some
> kind of key, create 64bit cipher text.
>
> All this done over 16 iterations. Kind of like a really simple DES.
>
> I'm no good at programming, and just new to ciphertext - its just a little
> part of my school course.
>
> I was thinking, getting the input and key to binary, then XORing them,
then
> for each result, XORing it with the key.
>
> Will this work, or be reversible?
>
> Can anyone point me to tutorials/examples of something like this.
>
> Thanks for any help!!
> Paul
>

With so many good ciphers out there, I'm not sure why I'd want to trust my
secrets to one that's not very good, but here is a very simple cipher that

Choose a 64-bit key: 0123456789abcdef (or any other value)

Break the 64-bit key into 16 equal pieces:
0 1 2 3 4 5 6 7 8 9 a b c d e f

Create sixteen 32-bit words by replicating the pieces
eight times:

00000000 11111111 22222222 33333333 ... ffffffff

Now, take your 64-bit data block and divide it into two 32-bit parts. Call
the parts L (left) and R (right).

For the first round, calculate

L(new) = R xor (00000000 xor L)
R(new) = L xor 00000000

For the second round, let R = R(new) and L = L(new) and calculate:

L(new) = R xor (11111111 xor L)
R(new) = L xor 11111111

For the third round, let R = R(new) and L = L(new) and calculate:

L(new) = R xor (22222222 xor L)
R(new) = L xor 22222222

Continue through the sixteenth round:

L(new) = R xor (ffffffff xor L)
R(new) = L xor ffffffff

Join the two 32-bit words, L(new) and R(new) to make the 64-bit ciphertext.

To decrypt, use the following pattern:

L(new) = R xor ffffffff
R(new) = L xor R

L(new) = R xor eeeeeeee
R(new) = L xor R

L(new) = R xor dddddddd
R(new) = L xor R

and continuing to

L(new) = R xor 00000000
R(new) = L xor R

Then combine L(new) and R(new) to yield the 64-bit plaintext.

===========================================================

The output below shows intermediate results from a program that does exactly
this, starting with a key value of 0x0123456789abcdef and a plaintext string
of "The dogs". It produces a 64-bit ciphertext value that it then reverses
into the original 64-bit plaintext.

Key Value: 01234567 89ABCDEF

Key[ 0] = 00000000
Key[ 1] = 11111111
Key[ 2] = 22222222
Key[ 3] = 33333333
Key[ 4] = 44444444
Key[ 5] = 55555555
Key[ 6] = 66666666
Key[ 7] = 77777777
Key[ 8] = 88888888
Key[ 9] = 99999999
Key[10] = AAAAAAAA
Key[11] = BBBBBBBB
Key[12] = CCCCCCCC
Key[13] = DDDDDDDD
Key[14] = EEEEEEEE
Key[15] = FFFFFFFF

Plaintext: The dogs = (20656854 73676F64)

Encrypting:
Round ----L--- ----R---
0: 20656854 73676F64
1: 53020730 20656854
2: 62767E75 42131621
3: 02474A76 40545C57
4: 71202512 31747945
5: 04101813 35646156
6: 64212C10 51454D46
7: 53020730 02474A76
8: 26323A31 24757047
9: 8ACFC2FE AEBAB2B9
10: BDECE9DE 13565B67
11: 04101813 17464374
12: A8EDE0DC BFABA3A8
13: DB8A8FB8 64212C10
14: 62767E75 06575265
15: 8ACFC2FE 8C98909B

Decrypting:
Round ----L--- ----R---
1: 8ACFC2FE 8C98909B
2: 62767E75 06575265
3: DB8A8FB8 64212C10
4: A8EDE0DC BFABA3A8
5: 04101813 17464374
6: BDECE9DE 13565B67
7: 8ACFC2FE AEBAB2B9
8: 26323A31 24757047
9: 53020730 02474A76
10: 64212C10 51454D46
11: 04101813 35646156
12: 71202512 31747945
13: 02474A76 40545C57
14: 62767E75 42131621
15: 53020730 20656854

Plaintext: 20656854 73676F64
Plaintext: The dogs

## Relevant Pages

• RE: WEP attacks based on IV Collisions
... > figure out what you need to XOR the plaintext with to get the ... > ciphertext, one bit at a time to recover the key sequence of n ... you'd XOR the plaintext and ciphertext. ... XOR 10111011 = Secret Key ...
(Pen-Test)
• Re: How good an encryption algorithm is this?
... >> know both a plaintext and a ciphertext for some message ... This is pretty much what happens with any encryption algorithm that uses ... XOR alone. ...
(microsoft.public.vc.language)
• Re: How good an encryption algorithm is this?
... >> know both a plaintext and a ciphertext for some message ... This is pretty much what happens with any encryption algorithm that uses ... XOR alone. ...
(microsoft.public.dotnet.languages.csharp)
• Re: encryption using a block cipher // ? size limit of plaintext
... The attacker finds two ciphertext blocks C_and C_that are the same. ... The attacker knows CXOR C(the XOR of the two blocks in the ... two plaintext blocks whose ciphertext matches. ...
(sci.crypt)
• Re: decrypting a XOR of two plaintexts
... >> If you have the plaintext and the associated ciphertext, you can XOR ... >> plaintext messages with the ciphertext to get the keystream. ...
(sci.crypt)