Cryptography 1

1 'Secret Key' , 'One Time Pad' or  a 'Vault'

 The pages on this site are (at the time of writing) concerned only with those systems that  may be recognised by the terms 'Private Key' and 'Public Key'.  Note that since this is
page describes software, the word code means code as in 'source code'  , not ' secret code!'  .
This page contains a workable demo of of an encryption utility and key generation tool. They were not intended as windows programs , hence they have no friendly GUI, and
just work on processing  plain text files. A link to a single archive containing these tools is given below. The archive contains all source and win32 executables , No formal instructions
have been written as yet. If  that hasn't put you off, then download the archive .....

Encryption tools         <-- download from this link.
 
Have a rummage through the archive, there are two directories, 'KeyGen2' and 'Vault'. The release folder of these contains typical intialisation files and test files.
The initialisation files do (just about) explain how to use them. More detailed instruction will follow, however, if you have no manners you may scroll down to them,
or you can read the following waffle.It might provide a useful   overview of ciphers and cryptography, but then again it just induce a deep torpor that you may never recover from.

Introduction to cryptography (do not read while driving or operating heavy machinery)

Note that there are quite specific definitions of the terms 'cipher' , 'encryption' and 'code' . However, here, were are going to lump it all together and call it all cryptography.
Top of the page referred to 'Private Key' and 'Public Key' systems. I'm going to make a wild generalisation here, which an expert may shoot down in flames,

            All  public Key systems are Theoretically breakable
            Private Key Theoretically may be unbreakable.

This may look like I'm flying the flag for Private Key systems. Not so . The effectiveness does depend on a various factors of implementation. The purpose
of  those statements  is to indicate a fundamental difference between the two. Generally, public key systems (more accurately key-pair systems) use an assymetric pair of algorithms
(an easy and a hard one, one to encrypt, one to decyrpt.) It is the mathematical difficulty of de-cryption without the key that is the protection. If you are still reading,
then you will be pleased to know I'm saving that for another day. We are going to look at private key systems. These are easier to understand and implement. Some of the
stuff here will be useful if progressing to more complex methods.

Recalling that Cryptography is making something unintelligible to anyone who does not posses the tools/knowledge/key/interest  to reverse whatever you did to it. The simplest is the
childish 'a=1, b=2, c=3.....'  (Ok, no one can really call that cryptography, its a cipher ).  It doesn't matter what the symbols are (eg 'pig-pen' )  that can be broken by statistical
analysis - assuming the message is long enough  (the relative fequency of the letters of the alphabet is quiet consistent over any given passage of normal english). There is
Sherlock Holmes story ( I think it's called 'The Adventure of the Dancing Men' or something like that that exposes this). So we are not interested in that kind of thing.
All the same, its worth remembering the notion of 'a=1, b=2 ' etc, not as the encryption itself, but as a means to being able to perform maths on the alphabet.

A private key system is described here, in simplest (but correctly functional) terms. For the purposes of the explanation, a limitation is imposed in that
the message consists solely of a 27 character alphabet (including a space!)
Think of a private key as simply being a list of random numbers. Ideally the list should be at least as long as the message to be encrypted Recalling the
'a=1 ' ; 'b=2'   thing,  letters in the message are mapped to the corresponding number. The key is used to modify the numbers - the first number in the key is
added to the first 'number' of the message, the second number in the key is added to the second 'number' in the message, and so on. If the key is not as long as the message, then eventually
the key will have to be 'recycled' - just start using it from the first in the list .
The resulting list of numbers is then mapped (   1= a, 2= b,  etc). back into letters. Hang on! any of you who are not yet comatose ,will have noticed that sometimes the resulting
number will be greater than 27! arrrgghh! . Don't panic. Just subtract 27. If it's still greater than 27, do it again., and again.until 27 or less. Don't subtract from anything that is not more than 27.
Then re-map back to alphabet. Actually, its not compulsory to map back to alphabet, but it looks better, and will give you a coded message exactly the same size as you started with.
This message can be safely emblazoned across the side of a bus as a means of delivery, assuming that only the intended recipients have a copy ofthe key.

Encryption example:

Key ;      1,4,9,23,48,2570,76, 345  (where the key here has exactly the same length as message, so they map one to one....
Message:  tea time 

1: translate message to numbers
       t= 20 ., e=5 , a = 1  'space' = 27 ,  t = 20 , i= 9, m=13 , e=5

2 ; add the corresponding key  (number) member to the letter of message;  (here the message is shown as letters again, so the key can be seen!).
(Key members in bold)

          t + 1 = 21 ,  e + 4 = 9,  a + 9 = 10 , 'Space' + 23 = 60,   t + 48 = 68 , i + 2570 = 2579, m + 76 = 89,  e + 345 = 350

So our encoded message is currently

21,9,10,60,68,2579,89,350

Mapping this back to alphabet where possible (leave the over 27's for now..)

21=  u,  9 = i , 10 = j , 60 = 60, 68= 68, 2579=2579, 89 = 89, 350=350.

so the first few mapped nicely in range, but the rest need adjusting (get rid of 27's)

60-27 = 33,   -- still too big, 33 - 27 = 6,   so 60 = 6  = f  

68    is obviously 6 (from above) plus 8, =    14 = n

2579  will take a while .. But hang on....   2579/27= 95.518518518518    . take of the integer (95) and multiply the remainder (0.518518518) by 27 = 14 = n

89   looks like it will have 3 * 27 in it, so 89= 89-(2*27) = 89-81 = 8   =  h

350 -- work this one out in similar way to 2579-----   comes out as 26 = z

so our fully encrypted message now reads   uijfnnhz

which I am  sure you will agree bears no resemblance to tea time. The word has been utterly randomised.  Now then, a problem. What if, after encryiption, the last character was a 'space' (but was something
meaningful before)  you might easily lose it (literally not see it to de-crypt). Well, you might just get away with it. Maybe there could be a 'fudge code',  where if encryption creates a 'space' character, it is
replaced by perhaps an exclamation mark or an asterisk, or maybe a picture of a  walrus. Just thought I'd point that out.

Next, I will show the message being de-crypted. but not until I have had time to verify the above. result. If you look back at this page later, and it no longer says uijfnnhz , then i made a mistake.

4/3/14   (Pancake Day!)