Source Code + explanation of algorithm
Right... sorry for my last message, it is clear that I have not explained the algorithm properly at all. I include the C++ class that is the heart of the encryption (lets call it the encrypting engine... I like how it sounds ;)). Right. To the point. The algorithm uses private keys... actually 2 keys. Now, the equation I give is correct... I meant the two x. This is beacuse it iterates the formula.
So, x = h*(1-x) means that the new value for x uses h and the actual value of x...
The first key in the algorithm is x (call it x0 because it is the initial value for it). The second key tells the library how many times to iterate the function before returning x.
I could insert a third key that would change h, giving a new degree of freedom. But this is not implemented... so far.
Now, as I explained in the previous post, the function above presents chaotic behaviour for values of h close to 4... but never greater to 4. This is the main feature I wanted to exploit. However, the initial x (that is x0), must range between 0 and 1 otherwise the iterating function blows up after a few loops.
Lets say we want to encrypt the string "Encrypt this". It has a length of 12 bytes. what I do is get the first four bytes ("Encr"). Use the initial value for x (that is x0 which is the first key), iterate the function a number of times given by the second key and obtain a new value for x. Because that value of x is an integer (four bytes long), I use it to XOR the first four bytes from the string... and the result is the encrypted string. I then read the next four bytes ("ypt "), iterate the function again, but this time use the value previously obtained (not x0 again, but the x we obtained in the previous encryption) and carry on like this until we run out of bytes to encrypt.
To decrypt, we simply use the same keys and repeat the process... the end result is the original string. And that is all the secret to it.
Comments on the source code. The source code is not commented, so it might be messy to follow, but I hope that with my explanation it gets easier. Probably the code can be improved for speed, or clarity, but this is what I can do. If any of you has any comments on it, please let me know. The class includes methods to recall the original value of x (x0, which is one of the keys). I do not include the source code for the program itself, which is actually unimportant for the encryption. I created another class for encrypting files and putting them together into a single file... but again that has naothing to do with the encrypting technique or code itself.
Thank you for your comments