Rated an average of 4.6667 stars by 3 people

Crypt Password #3

Script Details:
Added on March 15, 2009 by Speedy. Last modified March 15, 2009.
Speedy accreditted the script to himself.

Description:
This is the 3rd and probably not the final password crypt script I'll write. About function CryptPass(): This creates a random string from the name of a hash algorhythm, and splits it up in 2 and wraps it around the sha1() crypted string. Returning a long string. About function DecryptPass(): This retrives the password string hidden between the 2 random wrappers created in CryptPass().

Tags: crypt, password, security

Instructions:
Crypt the password:
$pass = CryptPass('password');

Retrive the password:
$pass = DecryptPass('password');

------
One of my results:
Word i chose as my password: mypass
CryptPass('mypass') returned: 398b7381b88d869791dfd9ddb4198affc5c194cd8ce6d338fde470e2d8c48359152548d0

DecryptPass() returned: 91dfd9ddb4198affc5c194cd8ce6d338fde470e2

Code:

<?php
# Snippet from PHP Share: http://www.phpshare.org

// Crypt function
function CryptPass($password)
{
    
$r rand(024);
    
$algo hash_algos();
    
$hash hash($algo[$r], $password);
    
$hashhalf strlen($hash) / 2;
    
$hsize[1] = substr($hash0$hashhalf);
    
$hsize[2] = substr($hash$hashhalfstrlen($hash));
    
$pass $hsize[1] . sha1($password) . $hsize[2];
    return 
$pass;
}

// Decrypt function
function DecryptPass($password)
{
    
$orig_length 40;
    
$total_length strlen($password);
    
$hash_break = (($total_length $orig_length) / 2);
    
$orig_pass substr($password$hash_break$hash_break $orig_length);
    
$orig_pass substr($orig_pass0$orig_length);
    return 
$orig_pass;
}
?>

Review this PHP Script:

Rating:

Comments:


Login

User:
Pass:

Register

Not a member? Register today and receive the many free benefits of being a member!

Advertisements