*I am keeping this site for my reference but in the future, I going to develop online encryption here based on CodeMixer.*

# Introduction to a Pseudorandom One Time Pad software techniques.

This is a tutorial about the Pseudorandom One Time Pad (Pseudorandom OTP) software techniques which I used when developing CodeMixer software. In the end, it will not be even Pseudorandom OTP, but slightly different encryption technology (new one) with output similar like Pseudorandom OTP.

Off course, it is not about how to replace current encryption methods. It is just a discussion how to solve OTP problems differently. Feel free to contact me through my contact webpage.

When I look at some website tutorials about “One Time Pad (OTP)” and Pseudorandom OTP software, I find that I do not agree with them. They always finish with the comments about the problems like: random key problem, cipher key length problem, etc…, but they do not look for the solutions.

When I developed an encryption software “CodeMixer”, I got over some of the problems my own way, which I like to share and discuss with you. The techniques are maybe not the perfect but they could be very easy explained and used. All you need is a paper and a pen, for working with examples you can download ” CodeMixer “. I do not show you a source code, most of you are probably the better programmers like me and you know how to apply these techniques to your code yourself. For a non-programmers, you can still follow the theory with the pen&paper.

I hope that at the end we will get something which could remove some of the disadvantages which has ” Pseudorandom OTP software”.

The next chapter is about basic of One Time Pad, just what you need for this tutorial.

# One Time Pad overview.

These are some basic term which we use:

**Data for encryption:**we will use plain text for now, but in real world you can use any data.**Cyphertext:**is result of our encryption, the data are encrypted now.**Cypher key**: One Time Pad (OTP) use Symmetric-key which mean that you use same cypher (key) for the encryption and for the decryption. I could say that this is core of OTP. You should take care of 3 things:- Length of the key – it must be at least the same size like the text. Be careful that the key ‘abcdabc’ is not OTP but Vigenere cipher – it is twice ‘abcd’ second is just not finished. More at the ‘Randomizer chapter’.
- The key should be truly random, ‘abcdefg’ is not random. Anyway, what is truly random? How do you know difference if I give you two keys, which is truly random and which is pseudorandom?
- The key must be used just one times for encryption. I think that this is probably the biggest problem for pseudorandom software and I will write about it later. When the key is used more times, it is easy to break it. For now, we just pretend that we will never use the same key.

**Technique**, which we use for encrypting. Some tutorials show how to do OTP in what I call “High level” – like: Take text ‘HELLO’ and key ‘ASDWI’ a you use modulo (26) – (Capital letters of the alphabet) and you get e.g. ‘NUTOO’.

For our purpose, we need to look a bit deeper and look at ‘low level’. We take text and look at it in binary. In this part of tutorial, we use classic XOR Boolean method.

*XOR principles:*

*if a=0 and b=0 result=0*

*if*

**a**=0 and**b**=1**result**=1*if*

**a**=1 and**b**=0**result**=1*if*

**a**=1 and**b**=1**result**=0*Example of encryption:*

**a**) Text in binary: 0111 0111 0110 1111 0111 0010 0110 0100 — text ‘word’ in text editor

**b**) Random key: 0110 0101 1100 1010 0011 0111 0010 1101

**result**) XOR: 0001 0010 1010 0101 0100 0101 0100 1001 — your cyphertext in binary

*Example of decryption:*

**a**) Cyphertext in binary: 0001 0010 1010 0101 0100 0101 0100 1001

**b**) Random key: 0110 0101 1100 1010 0011 0111 0010 1101

**result**) XOR: 0111 0111 0110 1111 0111 0010 0110 0100

Well that is all from classic One Time Pad, later parts will apply slightly different techniques and will create a new encryption technique.

# New One Time Pad Technique

## A Key pointing to a Text value.

As you can see below, where is number “1” in our key we switch values of text to opposite values. Zero values live text values unchanged. So, number “1” of the key is command for some action, in this example changing values of text to opposite values. Opposite values for “0” is “1” and for “1” is “0”.

Key | 0 | 1 | 1 | 0 | 0 |

Text | 1 | 0 | 1 | 0 | 1 |

Result | 1 | 1 | 0 | 0 | 1 |

We can see that a key’s second and third numbers are “1” and that this numbers pointing to the text values “0” (second number in text) and “1” (third number in text) and they change values to opposite value.

And here I’m leaving traditional One Time Pad – XOR technique and I’m going apply my own technique which l like to show you. I will call it a Switching values technique for now.

What if we instead of changing values (XOR), we just add or remove values in result, depending on some circumstances. The main principle is same as XOR. We use Symmetric-key encryption again. First time run is encryption, second time run is decryption. But big difference is that the result size could vary from the basic text size.

Here we go: we have 3 basic values which we can switch for theirs opposite values and vice versa. When the key point to text and text has value “00” we switch value in result to “010”. If the key point to “010” we switch value to “00”. See table.

Switching values table | ||||

Basic value | 00 | 11 | 011 | Opposite value |

Opposite value | 010 | 101 | 100 | Basic value |

**Example:**

We have a Text: 0 0 1 1 1 1 0 1 0 1 1 0 0 1 0 1 0 0 1 0

First, we break text into small parts based on ours table: 00 11 11 010 11 00 101 00 10 – -> last part which is not finished “10” (it is not in table) we can leave as it is.

Next, we give the key value to each part of the text. And apply rules of Switching values table. We switch just parts were key is pointing to “1”.

Encryption: | |||||||||

Text | 00 | 11 | 11 | 010 | 11 | 00 | 101 | 00 | 10 |

Key | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | ignore |

Cyphertext | 00 | 101 | 11 | 010 | 101 | 010 | 11 | 00 | 10 |

Decryption: | |||||||||

Cyphertext | 00 | 101 | 11 | 010 | 101 | 010 | 11 | 00 | 10 |

Key | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 | ignore |

Text | 00 | 11 | 11 | 010 | 11 | 00 | 101 | 00 | 10 |

Once again this is just my view of how we can use One-time pad technique differently. Maybe I am missing something but so far, I do not see any problem with it. Let me know what do you think about it.

# Randomizer

…coming….