Treat your password as an array, step through it, and apply the changes letter by letter.
Slightly OT - What are you trying to accomplish? All you are really doing is inverting the password -- isn't that one of the first things a cracker will try? (If answered earlier in thread, ignore.)
Cheers - Miles
At 10:56 PM 4/9/2003 -0400, Chris Payne wrote:
Hi there Everyone,
Here's a better example of the problem i'm having, there is probably a MUCH better way to do this, but here goes.
I am using the following code:
$passroutine = 'abcdefghijklmnopqrstuvwxyz';
$passroutine = str_replace("a", "z", $passroutine); $passroutine = str_replace("b", "y", $passroutine); $passroutine = str_replace("c", "x", $passroutine); $passroutine = str_replace("d", "w", $passroutine); $passroutine = str_replace("e", "v", $passroutine); $passroutine = str_replace("f", "u", $passroutine); $passroutine = str_replace("g", "t", $passroutine); $passroutine = str_replace("h", "s", $passroutine); $passroutine = str_replace("i", "r", $passroutine); $passroutine = str_replace("j", "q", $passroutine); $passroutine = str_replace("k", "p", $passroutine); $passroutine = str_replace("l", "o", $passroutine); $passroutine = str_replace("m", "n", $passroutine); $passroutine = str_replace("n", "m", $passroutine); $passroutine = str_replace("o", "l", $passroutine); $passroutine = str_replace("p", "k", $passroutine); $passroutine = str_replace("q", "j", $passroutine); $passroutine = str_replace("r", "i", $passroutine); $passroutine = str_replace("s", "h", $passroutine); $passroutine = str_replace("t", "g", $passroutine); $passroutine = str_replace("u", "f", $passroutine); $passroutine = str_replace("v", "e", $passroutine); $passroutine = str_replace("w", "d", $passroutine); $passroutine = str_replace("x", "c", $passroutine); $passroutine = str_replace("y", "b", $passroutine); $passroutine = str_replace("z", "a", $passroutine);
which is SUPPOSED to replace letters, a because z and so on, but after it gets to m it screws up and displays:
abcdefghijklmmlkjihgfedcba
How can I do the above code in such a way that it won't produce this problem?
Any help will be greatly appreciated :-)
Regards
Chris
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php