A Caesar Shift Cypher with a twist

Anything related to software

A Caesar Shift Cypher with a twist

Postby artmaker on Thu Jul 22, 2010 2:31 am

Caesar Shift Cypher

----------ENCODE A FILE----------
Seed a Pseudo Random Generator - Seed! (User Determined Value - Single Precision, floating point)
Select Offset into the Random Stream - Offset! (User Determined Value - Single Precision, Integer)
Dummy! RND Loop to Offset! value
START: (Label)
Get a Byte (8 bits) from the DECODED file
Grab a Pseudo Random Number from 1 to 14 and Store in Varable1 (Integer)
Dummy! RND Loop to Variable1 value
Grab a Pseudo Random Number from 1 to 14 and Store in Varable2 (Integer)
Dummy! RND Loop to Variable2 value
Grab a Pseudo Random Number from 1 to 254 and Store in Varable3 (Integer)
Dummy! RND Loop to Variable3 value
Split the Decoded Byte into two Nibbles (4 bits each, Decimal Value 0 to 15)
Add Variable1 to the High Nibble's Decimal Value
If the Addition is > 15 then
Addition = Addition - 16
Add Variable2 to the Low Nibble's Decimal Value
If the Addition is > 15 then
Addition = Addition - 16
Concatenate the High & Low Nibbles into a new Byte
Add Variable3 to this new Byte's Decimal Value
If the Addition is > 255 then
Addition = Addition - 256
Put this resulting Byte into the ENCODED file
Loop to START until done



Caesar Shift Cypher

----------DECODE A FILE----------
Seed a Pseudo Random Generator - Seed! (User Determined Value matching ENCODE - Single Precision, floating point )
Select Offset into the Random Stream - Offset! (User Determined Value matching ENCODE - Single Precision, Integer)
Dummy! RND Loop to Offset! Value
START: (Label)
Get a Byte (8 bits) from the ENCODED file
Grab a Pseudo Random Number from 1 to 14 and Store in Varable1 (Integer)
Dummy! RND Loop to Variable1 value
Grab a Pseudo Random Number from 1 to 14 and Store in Varable2 (Integer)
Dummy! RND Loop to Variable2 value
Grab a Pseudo Random Number from 1 to 254 and Store in Varable3 (Integer)
Dummy! Loop to Variable3 value
Subtract Variable3 from the Encoded Byte's Decimal Value
If the Subtraction is < 0 then
Subtraction = Subtraction + 256
Split the results into two Nibbles (4 bits each, Decimal Value 0 to 15)
Subtract Variable1 from the High Nibble's Decimal Value
If the Subtraction < 0 then
Subtraction = Subtraction + 16
Subtract Variable2 from the Low Nibble's Decimal Value
If the Subtraction < 0 then
Subtraction = Subtraction + 16
Concatenate the High & Low Nibbles into a new Byte
Put the resulting Byte into the DECODED file, or Display on Screen.
Loop to START until done.

**********************************************************************************
NOTES:

The "Dummy! Loops that I use are there to prevent any Pseudo Random Number' "group patterns" from ever being used more that once. A lot of Pseudo Random Generators "loop back" on themselves after several thousand calls.

Notice the procedural order is changed when decoding a file

The ENcoding and DEcoding processes are completely symmetrical:

1. If you ENcode a DEcoded File, the result is an ENcoded file. The ENcoded file would have to be DEcoded to restore.

2. If you DEcode a DEcoded File, the result is an ENcoded file. The ENcoded file would have to be ENcoded to restore.
artmaker
 
Posts: 13
Joined: Thu Jul 08, 2010 3:11 am

Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron