Re: Hash function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hope this is what your looking for...

<?php
/**
 * This is a part of the SN1000 System
 *
 * @author Hans Åhlin
 * @copyright (C)2009 Hans Åhlin
 * @owner Hans Åhlin
 * @version 1.000.000
 * @contact info@xxxxxxxxxx
 *
 * Copyrighted by the owner of SN1000
 * ALL COPYING, PUBLISHING AND EDITING WITH OUT THE
 * COPYRIGHT HOLDERS WRITTEN PERMISSION IS FORBIDDEN,
 * THIS INCLUDES THE CODE, TEXT, GRAPHICS AND SOUNDS.
 * For more information and/or questions please
 * contact us at info@xxxxxxxxxx Including the
 * concerning page file name and dns address
 */	

if(__DEBUG__ == 1){
	
	$TestPW = 'This is the test password!!!';
	
	echo "\n*****************************************\n";
	echo "** PASSWORD HASH FUNCTION\n";
	echo "** snlib_hash_password()\n";
	echo "*****************************************\n";
	echo "The test password: $TestPW";
	echo "\n";
	echo snlib_hash_password($TestPW);
	echo "\n*****************************************\n";
}

/**
 * This function salts and scrambles the password for higher security
 *
 * @version 1.000.000
 * @param $Password
 * @return SHA1
 */
function snlib_hash_password($Password){
	
	$PWLength = strlen($Password);
	
	if(__DEBUG__ == 1){
		
		echo 'The length of the test password: ';
		echo $PWLength;
		echo "\n";
	}
	
	$ScrambledPW = "";
	$i = 0;
	
	while($PWLength != 0){
		
		$PWLength--;
		
		$ScrambledPW .= $PWLength . $Password[$PWLength] . $Password[$i] . $i;
		
		$i++;
			
	}
	
	if(__DEBUG__ == 1){
		
		echo 'The scrambled test password: ';
		echo $ScrambledPW;
		echo "\n";
	}
	
	$PasswordHASH = sha1($ScrambledPW);
	
    return $PasswordHASH;
}
?>

For legal purposes i her grant you all to use this file fore any
purpose, and for the same reason i can not take away the copyright
notice...

2009/11/9 Ali Asghar Toraby Parizy <aliasghar.toraby@xxxxxxxxx>:
> hi friends
> I need a hash function to build a Unique serial number by mixing a request
> code and a user name
> request codes are strings like this: They are literally HEX codes of MAC mac
> addresses.
> "002314EFD000544AB05345300045675609782123C3254B312123D12312EE13123F123D123123E00000000E00000000E0000000E0000000E0000000E00000000E00000000"
> i want to create a function that mix together this request code with user
> name that user entered and create new serial number.
> What implications i have to satisfy to create such hash function in php?
> Thanks for any suggestion
>



-- 
MvH / Hans Åhlin
Tel: +46761488019
http//www.kronan-net.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux