PDA

View Full Version : A quick and simple code.



Grognaurd
Jun 22nd, 2011, 08:40 AM
Two parties to be in contact. Watches are synced.
Before the sender makes contact, he writes out the alphabet and subtracts the hour of the day and writes this down underneith the alphabet.
If it is 1:00, B becomes A. A becomes Z
Write out what is to be coded in the "proper" letter.
Send the code

Reciever writes down the letters and works in reverse.

If the reciever has lost the watch, on an open mic, he can ask What time is it, my watch stoped a while ago.

Deep encryption? No. Easy to code and decode? Yes. Cracking the code is more difficult that it sounds, because almost every mesage will be sent at a different hour.

j0be
Jun 22nd, 2011, 08:44 AM
Cryptography is an amazing field, where there can be so many things done to a piece of data.

It's pretty simple actually to convert any word into a number. (Think hexadecimal, but with base 36 instead of 16). A friend and I used to pass notes using just that. Easy if you know what you're doing, but it's not just a simple replacement algorithm, because it uses positional variance

Ron = 35879 for example



R = 34992 [27*(36^2)]
o = 864 [24*(36^1)]
n = 23 [23*(36^0)]
_________
35879

Grognaurd
Jun 22nd, 2011, 09:26 AM
Ok, But for my little brain I am going to stick with a base 10 subtraction. But, if you do not include a random contribution, it will be easier to break because the sample size increases. English (an others) do not have equal possibilities for each letter. Worse, Letters have a distinct Dependent probability. For example, Q. The next letter has very few possibilities. So, Q is not 1 in 26. Say it is more like 1 in 100. Then, the next letter is most commonly a U. I used to have to do this crap. Ugh, Bell's Information theorum, no... go away....

j0be
Jun 22nd, 2011, 09:28 AM
Ok, But for my little brain I am going to stick with a base 10 subtraction. But, if you do not include a random contribution, it will be easier to break because the sample size increases. English (an others) do not have equal possibilities for each letter. Worse, Letters have a distinct Dependent probability. For example, Q. The next letter has very few possibilities. So, Q is not 1 in 26. Say it is more like 1 in 100. Then, the next letter is most commonly a U. I used to have to do this crap. Ugh, Bell's Information theorum, no... go away....

Actually the awesome thing about this was the positional variance.
The 'R' in Ron (34992) is not equal to the 'R' in 'Roof' (1259712)

A randomizing factor could be added, but most times, it wouldn't be necessary

Grognaurd
Jun 22nd, 2011, 09:39 AM
hmmm... What does 12378387 mean?

If it is too big, drop a number or two off? I do not see how it works because multiple sums of different letters may give the same final value. But, maybe each one of these is unique. Not smart enough to tell either way without thinking about it.

j0be
Jun 22nd, 2011, 10:06 AM
hmmm... What does 12378387 mean?

It means "7DB83". Converting to different bases is something kind of hard to describe, but each value is unique. Converting to base 36 to base 10 (what we used as the code) is easiest because it is the standard numbers we work with every day. This makes it easier than converting base 36 to base 2 for example.

Basically if you mentally picture buckets/slots and not numbers. It makes more sense that way.
Each bucket is equal to the base to the power of the position.
For example: 6 is equal to 6 * 10 ^ 0 (the 1s place);
For example: 20 is equal to 2 * 10 ^ 1 (the 10s place);
For example: 400 is equal to 4 * 10 ^ 2 (the 100s place);

Each bucket you have in that base adds one to the exponent of that bucket. After that you add the totals together
For example: 426 is equal to (6 * 10 ^ 0) + (2 * 10 ^ 1) + (4 * 10 ^ 2)

If you grasp this you can convert to any base as long as you are consistent on your representation of them. Most commonly, the alphabet is used to represent numbers larger than ten is most bases. EG: A=10, B=11, C=12, ...

To convert to other bases from base 10, you just need to figure out their buckets. Let's convert 13 (in base 10) to binary (base 2) for example. Binary only has 0 and 1 due to its base. So let's figure out our buckets.
2^4,2^3,2^2,2^1,2^0 (you can keep going infinitely further to the left, but we'll stop at that.)
That makes these places:
16 place, 8 place, 4 place, 2 place, 1 place

Now we look at the number we want to convert (13).
Edit: Previous explanation was way too wordy. Check the spoiler at the end if you want to see what I had written. Let me simplify;
We are going to look at the buckets, starting on the left. At each position we are going to see how many times that bucket goes into our running total, then subtracting that from our running total. Our running total starts with the base 10 number (13). So let's start: the first bucket is 16. It goes into 13 zero times, so our first binary number is '0'. According to our instructions we now subtract that total from our running total. So let's subtract. 13-(0*16)=13. (The zero is how many times 16 went into 13). It's still 13. Now we continue this for each subsequent bucket. Bucket 8 goes into 13 one time, so our next binary digit is '1'. Now we need to subtract that from our running total. 13-(1*8)=5. Bucket 4 goes into 5 one time, so our next binary digit is '1'. Subtract that from our running total. 5-(1*4)=1. Bucket 2 goes into 1 zero times, so our next binary digit is '0'. We subtract that from our running total. 1-(0*2)=1. No change. Bucket 1 goes into 1 one time, so our last binary digit is '1'. Let's subtract. 1-(1*1)=0. You should always end with a running total of 0. Now if we put all the binary digits together we have '01101'.

That is converting from base 10 to another base. Converting from any other base to base 10 is actually much easier. I'll just let the video below help me out.

Old Explanation
We start at the left and ask whether it is larger or equal to that bucket. 13 is not >= than 16, so our first binary digit from left to right is '0'. 13 is greater than 8, so we divide our number by that bucket without going over (8), and we get our next binary digit '1'. If you ever manage to put anything other than 0 as a digit, you then take the remainder of the division. (13-8=5). So now our running total is 5. Because 5 is greater than 4, we divide it, and get our next binary digit '1'. Then we subtract it from our running total to get a running total of '1'. 1 is not greater than 2 so we go to the next digit. 1 is greater than or equal to 1, so we now have our last binary digit '1'. You should always end with a running total of 0. Now if we put the binary digits in a row we have '01101'. 13 in decimal is equal to 01101 in binary.

j0be
Jun 22nd, 2011, 10:37 AM
Here's a video that helps describe it better. (converting from any other base to base 10)

http://www.youtube.com/watch?v=51I6b8Uw0rs