PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I wouldn't recommend using a Caesar cipher for passwords
But you're trying to increment and decrement character values using ++ and --. While this works for incrementing, you'll find that the PHP documentation specifically says that it doesn't work for decrementing.
To do the decrement, you have to convert the characters to a numeric value, then decrement, then convert them back to a character using the ord() and chr() functions.
greyhoundcode wrote:If you want to keep it really simple, the str_rot13() function encodes as well as decodes, though it's obviously not encryption as such.
Pity str_rot13() will only rotate 13 characters... it might be more useful if it allowed a second parameter identifying how many steps to shift each character by