|
Posted by Sjoerd on 02/17/06 15:11
Jeremy Deuel wrote:
> Just an Idea:
> In PHP, passwords for different purposes often are stored plaintext in
> the source. I often wondered, how this could be prevented.
Nice functions, and not that simple to decrypt.
People already thought about this, and came up with the following:
XOR "encryption": A bitwise XOR (exclusive or, ^ operator) is done for
every character of the string. The key is repeated, as in your example.
The advantage is that encryption and decryption uses the same function:
Doing a XOR on a string twice will result in the original string.
ROT-13: Rotate the alphabet with 13 positions: A becomes N, B becomes
O, etc. Because there are 26 letters in the alphabet, doing a ROT-13
twice will result in the original string.
Also take a look at str_repeat(), which can repeat the key so that it
is long enough. You can use the % operator instead of fmod().
[Back to original message]
|