• Log in or sign up for an account here: https://www.sythe.org/login

Password Protection[PHP]

Joined
Nov 18, 2011
Sythe Gold
0
Messages
8
Location
California
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;
	}
}
 
i would crack this code if you put it on a site....

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

Sprint™;10010778 said:
Generating a password with a combination of letters, alphabets and special chars, by default it generates 10 chars.

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

Code:
function RandomPasswordGeneration($passwordlength=10)
 {
 	// add numbers,alphabets and special chars
  	$random_chars = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%";
        $getstring = "";
	$password= "";
	// While loop will execute until the length of password reaches the $passwordlength
        while(strlen($password)<$passwordlength) 
	{
		 // returns a sigle character from the set of random_chars
		 $getstring = substr($random_chars, mt_rand(0, strlen($random_chars)-1),1);
		
		 //Avoid already existed character from the password.
		 if (!strstr($password, $getstring)) 
		 {
		     //append the generated value to password 
    		     $password .= $getstring;
    	         }
           }
    return($password);
}

echo "Random Password ".RandomPasswordGeneration(); 
//if you need a length of 8 chars, send the paratmeter in function as RandomPasswordGeneration(8);

THINK QUANTUM.
 
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.

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.
 
You should be using different salts for each password.

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.

You wouldn't be able to crack it unless you knew how it was hashed.
 
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.
 
Runescape Gamblingrunescape gambling
Back
Top