|
|
@@ -20,7 +20,7 @@ |
|
|
|
|
|
|
|
namespace codedweller { |
|
|
|
|
|
|
|
unsigned char MANGLER::ChaosDriver(void) { // Return the current |
|
|
|
unsigned char Mangler::ChaosDriver(void) { // Return the current |
|
|
|
return Fill[Fill[Position]^Fill[Position^0xff]]; // chaos engine output |
|
|
|
} // value. |
|
|
|
|
|
|
@@ -32,7 +32,7 @@ unsigned char MANGLER::ChaosDriver(void) { // Return the current |
|
|
|
// value of Position and determining the final output value and the Position |
|
|
|
// value itself is used to add complexity to the output. |
|
|
|
|
|
|
|
unsigned char MANGLER::Rotate(unsigned char i) { // Bitwise rotates i |
|
|
|
unsigned char Mangler::Rotate(unsigned char i) { // Bitwise rotates i |
|
|
|
return ( |
|
|
|
(i & 0x80)? // This operation is |
|
|
|
(i<<1)+1: // described without |
|
|
@@ -40,7 +40,7 @@ unsigned char MANGLER::Rotate(unsigned char i) { // Bitwise rotates i |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
void MANGLER::ChaosDriver(unsigned char i) { // Drives chaos engine. |
|
|
|
void Mangler::ChaosDriver(unsigned char i) { // Drives chaos engine. |
|
|
|
|
|
|
|
// First we move our mixing position in the fill buffer forward. |
|
|
|
|
|
|
@@ -86,21 +86,21 @@ void MANGLER::ChaosDriver(unsigned char i) { // Drives chaos engine. |
|
|
|
// same state with the same fill data characteristics or else the two |
|
|
|
// chaotic systems evolve to further divergent states. |
|
|
|
|
|
|
|
unsigned char MANGLER::Encrypt(unsigned char i) { |
|
|
|
unsigned char Mangler::Encrypt(unsigned char i) { |
|
|
|
unsigned char g = ChaosDriver() ^ i; // Take the output of the |
|
|
|
ChaosDriver(g); // chaos engine and use it |
|
|
|
return g; // to moduleate the input. |
|
|
|
} // Then drive the engine |
|
|
|
// with the encrypted data. |
|
|
|
|
|
|
|
unsigned char MANGLER::Decrypt(unsigned char i) { |
|
|
|
unsigned char Mangler::Decrypt(unsigned char i) { |
|
|
|
unsigned char g = ChaosDriver() ^ i; // Take the output of the |
|
|
|
ChaosDriver(i); // chaos engine and use it |
|
|
|
return g; // to demodulate the input. |
|
|
|
} // then drive the engine |
|
|
|
// with the original input. |
|
|
|
|
|
|
|
MANGLER::MANGLER(void) : Position(0) { // The default constructor sets |
|
|
|
Mangler::Mangler(void) : Position(0) { // The default constructor sets |
|
|
|
for(unsigned int c = 0;c<256;c++) // the key to the root primary |
|
|
|
Fill[c]=(unsigned char) c; // value and Position to 0. |
|
|
|
} |