Password encryption and Sting Split Question.
Posted: Fri Nov 12, 2010 2:26 pm
Hi, I was bored yesterday and came up with this idea for password encryption.
Basically, take the password that the user supplies at registration and split it into individual characters. Assign a number to each character and then combine all the resulting numbers into a string. So instead of 2+2 = 4, 2+2 = 22. Then take this string and use it as a SALT for the md5 hashing of the pw.
This is the function that I made to achieve this. Please, comment on it because I'm pretty sure that there is a much more elegant way to achieve this or I did something wrong somewhere. Haven't had time to test it out yet.
Thanks! 
Basically, take the password that the user supplies at registration and split it into individual characters. Assign a number to each character and then combine all the resulting numbers into a string. So instead of 2+2 = 4, 2+2 = 22. Then take this string and use it as a SALT for the md5 hashing of the pw.
This is the function that I made to achieve this. Please, comment on it because I'm pretty sure that there is a much more elegant way to achieve this or I did something wrong somewhere. Haven't had time to test it out yet.
Code: Select all
function splitPw($inputstring) {
for($i=0;$i<strlen($inputstring);$i++)
{
$letterarray[]=$inputstring[$i];
if ($letterarray == 'a') {
$b[$i] = 1;
}
else if ($letterarray == 'b') {
$b[$i] = 2;
}
else if ($letterarray == 'c') {
$b[$i] = 3;
}
else if ($letterarray == 'd') {
$b[$i] = 4;
}
else if ($letterarray == 'e') {
$b[$i] = 5;
}
else if ($letterarray == 'f') {
$b[$i] = 6;
}
else if ($letterarray == 'g') {
$b[$i] = 7;
}
else if ($letterarray == 'h') {
$b[$i] = 8;
}
else if ($letterarray == 'i') {
$b[$i] = 9;
}
else if ($letterarray == 'j') {
$b[$i] = 10;
}
else if ($letterarray == 'k') {
$b[$i] = 11;
}
else if ($letterarray == 'l') {
$b[$i] = 12;
}
else if ($letterarray == 'm') {
$b[$i] = 13;
}
else if ($letterarray == 'n') {
$b[$i] = 14;
}
else if ($letterarray == 'o') {
$b[$i] = 15;
}
else if ($letterarray == 'p') {
$b[$i] = 16;
}
else if ($letterarray == 'q') {
$b[$i] = 17;
}
else if ($letterarray == 'r') {
$b[$i] = 18;
}
else if ($letterarray == 's') {
$b[$i] = 19;
}
else if ($letterarray == 't') {
$b[$i] = 20;
}
else if ($letterarray == 'u') {
$b[$i] = 21;
}
else if ($letterarray == 'v') {
$b[$i] = 22;
}
else if ($letterarray == 'w') {
$b[$i] = 23;
}
else if ($letterarray == 'x') {
$b[$i] = 24;
}
else if ($letterarray == 'y') {
$b[$i] = 25;
}
else if ($letterarray == 'z') {
$b[$i] = 26;
}
$pw == $pw.$b[$i];
}
return md5($pw.$inputstring);
}
$password = splitPw($_POST('password'));