- Impact
- 2
Well, adding SALT's to your passwords are basically an added security type of thing.
Usually people just add them to the back or front of the string or something of the sort. I broke up the password and salt and put them "side" of each other basically.
This script breaks up the md5 32-bit md5 password, adds a random SALT to it if you dont already have a SALT, then combines them and returns a 64-bit virtually unbreakable password (ofc anything can be broken, thats why I said "virtually" :P)
When using this with a DB, just add a field in the users table named SALT and insert the SALT when it is created. You will need to add some kind of user identifier with that also
Usually people just add them to the back or front of the string or something of the sort. I broke up the password and salt and put them "side" of each other basically.
This script breaks up the md5 32-bit md5 password, adds a random SALT to it if you dont already have a SALT, then combines them and returns a 64-bit virtually unbreakable password (ofc anything can be broken, thats why I said "virtually" :P)
PHP:
<?php
function add_salt ($password, $salt = FALSE)
{
// The number of characters you want in each piece of the array
$char_num = 4;
// The $password variable MUST be md5 BEFORE it is run through the script
// This splits the string into arrays of 4 characters
$string = str_split($password, $char_num);
if ($salt == FALSE)
{
// Create your own SALT
// We use MD5 on this method also to make sure its 32 characters
// This also makes it EXTREMELY harder to guess!
$salt = md5(uniqid(rand(), true));
}
// Now that the SALT is set or was already set, we can now divide the salt and
// start alternating entering the data
$salt = str_split($salt, $char_num);
$i = 0; // set it for the SALT identifier
foreach ($string AS $part)
{
$final_password[] = $part.$salt[$i];
$i++;
}
return implode($final_password);
}
$password = add_salt(md5("This is a password"));
echo $password;
?>
When using this with a DB, just add a field in the users table named SALT and insert the SALT when it is created. You will need to add some kind of user identifier with that also








