Adblock breaks this site

Password Protection[PHP]

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

  1. Sprintâ„¢

    Sprintâ„¢ Newcomer

    Joined:
    Nov 18, 2011
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    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;
    	}
    }
     
  2. sp for real

    sp for real Member

    Joined:
    Nov 17, 2011
    Posts:
    75
    Referrals:
    0
    Sythe Gold:
    0
    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.
     
  3. Sprintâ„¢

    Sprintâ„¢ Newcomer

    Joined:
    Nov 18, 2011
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    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.
     
  4. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    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.
     
  5. Nullware

    Nullware Guru

    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0
    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 >


 
 
Adblock breaks this site