1. How does the xor stream cipher algorithm work? The xor stream uses
the bitwise xor logic on two real numbers. The word bitwise denotes
that the real numbers are broken into binary (base 2) and compared
with the 'exclusive or' logic. Example:
Letter A = 97 ASCII
Letter C = 99 ASCII
algabraic:
97 xor 99 = x
97d = |0|1|1|0|0|0|0|1|
99d = |0|1|1|0|0|0|1|1|
xor = |0|0|0|0|0|0|1|0|
xor = (3 base10)
Notice the xor binary is false if the two bits
in the vector are equal and true if unequal.
The [or] logic states that:
'if this [or] that is true? Than I am too.'
The [xor] (or 'exclusive') logic is similar except
if both are false than residue is true. You can
use a calculator with the [xor] button to confirm
your results in both dec (base10) and bin (base2).
Mathematical Analogy of [xor] logic:
+6 * +6 = +36 (+ * +) = (+)
-6 * -6 = +36 (- * -) = (+)
-6 * +6 = -36 (- * +) = (-)
+6 * -6 = -36 (+ * -) = (-)
Note:
In the above operands, notice that they can
be applied in the oposite direction. This is
why the [xor] logic can be used for ciphering
code, it is reversible and can be deciphered.
2. The cipher steam is a 'stream' because the algorithm
lets the data values flow thru or 'stream' thru the
function returning the xor'd value one letter at a time.
A block cipher would count the values streaming thru
and shift the cipher key to offset regular patterns.
If throughout the entire cipher text the letters
a e i o u were to surface as q n t l p repectively,
it can be deciphered much easier thru pattern matching
attacks. Why? Because these are vowels and there is a
minimum of at least one in every word in the english
language. Then there are other letters which are not
present in [all] words but occur often. Watch Wheel of
Fortune and notice the contestants regularly pick some
constanants like 'r'. This is the weakness of a stream
encipher.
The block cipher on the other hand is not so easy to
decipher. Remember the block cipher shifts (or changes)
the encipher key on a reversible pattern.
For example every 10 characters the cipher key will be
recalculated with a reversible function. This will make
pattern matching attacks near imposible. The blow-fish
encipher algorithm is a 'block' cipher.
In my implementation of the xor cipher, I simply take
the data passed to the function and xor to the cipher
key passed to the function.
data: 'hello' -> xor function
ckey: '92' -> xor function
h -> ascii [xor] 92 = x
e -> ascii [xor] 92 = x
l -> ascii [xor] 92 = x
l -> ascii [xor] 92 = x
o -> ascii [xor] 92 = x
return 'xxxxx' or 'hello' [xor] 92
In the case that the key is a string or character
(not a real number), I simply get the ascii value
of the character (which is a real number).
The same function can be used to decipher the
ciphertext b/c the [xor] logic is reversible.
My [xor] cipher has been modified to return the
Unicode 2.0 standard which will allow large xor
cipherkeys to still be transfered in the ascii
format. This means that the results can be sent
with non mime-encoding email platforms. If you
xor a->97ascii by 200000, it will return a large
value, a value that has no ascii equivalent.
The non-unicode function returns a wildcard
representing the binary value.