Password Protection[PHP]

Discussion in 'Web Programming' started by Sprintâ„¢, Nov 18, 2011.

Password Protection[PHP]
  1. Unread #1 - Nov 18, 2011 at 9:31 PM
  2. Sprintâ„¢
    Joined:
    Nov 18, 2011
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0

    Sprintâ„¢ Newcomer

    Password Protection[PHP]

    Some people would probably call this over secure, others might call it not secure enough. Either way, this will hash your password pretty well. (Based on SHA512, but a little more secure.) Adds salt to the beginning, middle and end of the password, as well as hashing with SHA512 and changing the first half of the SHA512 with str_rot13.

    Instructions: Change your salts to whatever you'd like (make sure you don't use the ones shown in this tutorial, they probably wouldn't be that safe), then run it like a normal function.

    =========================================================

    Code:
    function warpMyPass($pass){
    	if($pass != null){
    		$salt1 = "SomeSalt";
    		$salt2 = "SomeMiddleSalt";
    		$salt3 = "SomeLastSalt";
    		if(strlen($pass) > 1){
    			$len = floor((strlen($pass)/2));
    			$first = substr($pass, 0, $len);
    			$last = substr($pass, $len);
    			$pass = $salt1.$first.$salt2.$last.$salt3;
    		}else{
    			$pass = $salt1.$pass.$salt3;
    		}
    		$pass = hash('sha512', $pass); //SHA is 128 characters long, by the way.
    		$len = floor((strlen($pass)/2));
    	        $pw = substr($pass, 0, $len);
    		$pw = str_rot13($pw);
    		$rest = substr($pass, $len);
    		return($pw.$rest);
    	}else{
    		return false;
    	}
    }
     
  3. Unread #2 - Nov 19, 2011 at 11:56 AM
  4. sp for real
    Joined:
    Nov 17, 2011
    Posts:
    75
    Referrals:
    0
    Sythe Gold:
    0

    sp for real Member

    Password Protection[PHP]

    i would crack this code if you put it on a site....

    maybe take your idea from your previous post and combine them?

    THINK QUANTUM.
     
  5. Unread #3 - Nov 19, 2011 at 3:31 PM
  6. Sprintâ„¢
    Joined:
    Nov 18, 2011
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0

    Sprintâ„¢ Newcomer

    Password Protection[PHP]

    I don't plan on using this script on any of my projects, I'm just posting these so that people who are wanting to learn PHP can get an idea of what they do, and how to write their own.
     
  7. Unread #4 - Nov 22, 2011 at 11:48 PM
  8. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    Password Protection[PHP]

    You should be using different salts for each password.

    You wouldn't be able to crack it unless you knew how it was hashed.
     
  9. Unread #5 - Nov 24, 2011 at 9:23 AM
  10. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    Password Protection[PHP]

    Since you would probably want to also return the salt(s) used during the hashing because you need them in your database, it might be better to return an array that contains them along with the hashed password.
     
< Need help with vB | Looking for some 1 to make me a runescape tracker site >

Users viewing this thread
1 guest


 
 
Adblock breaks this site