[advanced search]
Results from the most recent live auction are here.
21 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 08-11-2005, 10:28 AM   · #1
Outer
NamePros Member
 
Name: Corey
Location: Texas USA
Trader Rating: (1)
Join Date: Jan 2005
Posts: 71
NP$: 203.00 (Donate)
Outer is an unknown quantity at this point
Adding a SALT to your passwords

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)

PHP Code:
<?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


Please register or log-in into NamePros to hide ads
__________________
I wonder...
Outer is offline   Reply With Quote
Old 08-11-2005, 11:26 AM   · #2
Amnezia
SEO and Marketing Guy
 
Amnezia's Avatar
 
Location: Escaped from the zoo
Trader Rating: (8)
Join Date: Jul 2005
Posts: 907
NP$: 398.50 (Donate)
Amnezia has a spectacular aura aboutAmnezia has a spectacular aura about
Cancer Survivorship
very nice post! thanks for sharing
Amnezia is offline   Reply With Quote
Old 12-07-2005, 09:22 PM   · #3
allabout42
Senior Member
 
allabout42's Avatar
 
Name: Teddy
Location: Bay Area
Trader Rating: (97)
Join Date: May 2005
Posts: 1,496
NP$: 741.16 (Donate)
allabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud ofallabout42 has much to be proud of
Wildlife
Hmmm, this code script can be useful, thanks!
allabout42 is offline   Reply With Quote
Old 12-07-2005, 09:29 PM   · #4
axilant
Account Closed
 
axilant's Avatar
 
Name: Cody Selzer
Location: /etc/passwd
Trader Rating: (40)
Join Date: May 2004
Posts: 2,194
NP$: 0.00 (Donate)
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
Member of the Month
July 2005
Before anyone goes and tries this, the function str_split() requires php5.

http://us2.php.net/str_split

PHP Code:
if (!function_exists('str_split')){
     function
str_split($string, $split_length=1){

         if (
$split_length < 1){
           return
false;
         }

         for (
$pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length){
           
$chunks[] = substr($string, $pos, $split_length);
         }
         return
$chunks;
     }
   }

(first post on php.net documentation for str_split)

Just add that to your file before you go and use this on versions of php below 5.

Nice post

Cody
axilant is offline   Reply With Quote
Old 12-08-2005, 01:57 AM   · #5
snareklutz
 
Trader Rating: (39)
Join Date: Dec 2004
Posts: 1,055
NP$: 142.50 (Donate)
snareklutz is a name known to allsnareklutz is a name known to allsnareklutz is a name known to allsnareklutz is a name known to allsnareklutz is a name known to allsnareklutz is a name known to all
So why not just do

PHP Code:
$password = md5(sometext.$password);
__________________
My Afternic Names - no more sedo for me!!!
snareklutz is offline   Reply With Quote
Old 12-08-2005, 08:52 AM   · #6
Joe
NP Twin™
 
Joe's Avatar
 
Name: Joe
Location: Kent ~ U.K.
Trader Rating: (46)
Join Date: Oct 2005
Posts: 2,982
NP$: 1422.87 (Donate)
Joe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud ofJoe has much to be proud of
Save The Children
Originally Posted by axilant
Before anyone goes and tries this, the function str_split() requires php5.

http://us2.php.net/str_split

PHP Code:
if (!function_exists('str_split')){
     function
str_split($string, $split_length=1){

         if (
$split_length < 1){
           return
false;
         }

         for (
$pos=0, $chunks = array(); $pos < strlen($string); $pos+=$split_length){
           
$chunks[] = substr($string, $pos, $split_length);
         }
         return
$chunks;
     }
   }

(first post on php.net documentation for str_split)

Just add that to your file before you go and use this on versions of php below 5.

Nice post

Cody



cool, thanks for mentioning that!
__________________
Joe is offline   Reply With Quote
Old 12-09-2005, 07:42 AM   · #7
.:Mammoth261:.
NamePros Regular
 
.:Mammoth261:.'s Avatar
 
Name: Jamie Watson
Location: Midlands, England
Trader Rating: (4)
Join Date: Oct 2005
Posts: 309
NP$: 25.00 (Donate)
.:Mammoth261:. will become famous soon enough.:Mammoth261:. will become famous soon enough
Nice work, ill check it out, maybe use it soon for some things i will be working on
.:Mammoth261:. is offline   Reply With Quote
Old 12-09-2005, 08:06 AM   · #8
skrilla
Senior Member
 
Location: canada
Trader Rating: (34)
Join Date: Mar 2005
Posts: 1,008
NP$: 198.76 (Donate)
skrilla is just really niceskrilla is just really niceskrilla is just really niceskrilla is just really nice
very nice.. thank you
__________________
Come visit my Ebay Store
COME VISIT NOW!!! Sign up for adsense at www.ratemymug.com
This line is for sale PM for details
skrilla is offline   Reply With Quote
Old 12-09-2005, 11:46 AM   · #9
iNod
Eating Pie
 
iNod's Avatar
 
Name: Steve
Location: Canada
Trader Rating: (66)
Join Date: Nov 2004
Posts: 2,282
NP$: 91.30 (Donate)
iNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud ofiNod has much to be proud of
Special Olympics AIDS/HIV Cystic Fibrosis Save The Children Baby Health Cystic Fibrosis
Originally Posted by snareklutz
So why not just do

PHP Code:
$password = md5(sometext.$password);



PHP Code:
$password = md5("sometext".$password;


SALT is random characters. You can do that if you want.

iNod.
__________________
RegisterDub.com - 200th Customer Milestone
ZuneParts.net - International Zune Parts and Accessories
FeaturedFont.com - One Top Free Font a Day!
iNod is offline   Reply With Quote
Old 12-09-2005, 03:16 PM   · #10
theparrot
NamePros Regular
 
Trader Rating: (18)
Join Date: Mar 2004
Posts: 638
NP$: 435.60 (Donate)
theparrot is a jewel in the roughtheparrot is a jewel in the roughtheparrot is a jewel in the rough
Originally Posted by Outer
Well, adding SALT's to your passwords are basically an added security type of thi

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)



a salt does not make a password more unbreakable, it reduces the damage when one is broken as you can't reuse the same attack vectors on multi passwords at the same time.

Also, md5 should no longer be used.
__________________
Need a break? Check out TheDamnBlog.com
Free $6.95 directi accounts at Directi Name Bin
Instant free $8.95 eNom accounts at Dncube.com
theparrot is offline   Reply With Quote
Old 12-09-2005, 03:24 PM   · #11
maples
Account Closed
 
Trader Rating: (0)
Join Date: Dec 2005
Posts: 8
NP$: 0.00 (Donate)
maples is an unknown quantity at this point
that's very useful. thank you
maples is offline   Reply With Quote
Old 12-12-2005, 10:59 AM   · #12
Immersion
NamePros Regular
 
Trader Rating: (0)
Join Date: Oct 2005
Posts: 230
NP$: 183.20 (Donate)
Immersion is an unknown quantity at this point
thanks, i might try that. Now i jsut need to work out all about functions.
Immersion is offline   Reply With Quote
Old 12-12-2005, 12:49 PM   · #13
axilant
Account Closed
 
axilant's Avatar
 
Name: Cody Selzer
Location: /etc/passwd
Trader Rating: (40)
Join Date: May 2004
Posts: 2,194
NP$: 0.00 (Donate)
axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold
Member of the Month
July 2005
Originally Posted by theparrot
a salt does not make a password more unbreakable, it reduces the damage when one is broken as you can't reuse the same attack vectors on multi passwords at the same time.

Also, md5 should no longer be used.




Agreed. md5 can be cracked. Yep. It can be.

I suggest you all start using sha1 or sha2
http://php.net/sha1
axilant is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Totorial - Adding Music to your Site abacomedia Webmaster Tutorials 7 08-27-2005 08:12 AM
adding to google vichousefc Search Engines 11 07-27-2005 05:10 PM
Changing Account Passwords taheny The Break Room 0 11-16-2004 08:04 AM
Snapnames adding "New Preferred Access" registrars ExpireGuy Industry News 0 10-13-2004 04:32 AM
Window's passwords cracked in mere seconds. bobbi The Break Room 1 07-27-2003 03:17 AM

Site Sponsors
http://www.mobisitetrader.com/ Hunting Moon http://www.mobisitetrader.com/
Advertise your business at NamePros
All times are GMT -7. The time now is 09:32 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0