Subversion Repositories ALCASAR

Rev

Rev 1467 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
325 richard 1
<?php
2
function da_encrypt()
3
{
4
	$numargs=func_num_args();
5
	$passwd=func_get_arg(0);
1468 richard 6
	if ($numargs == 2){ //only to test or change password (keep the old algorythm and salt)
7
		$salt=func_get_arg(1);
8
		return crypt($passwd,$salt);
9
	}
1467 richard 10
	# set the salt and the algorithm
11
	$shuf = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"),0,8);
1464 richard 12
	# hash md5 > empreinte du mot de passe sur 22 caracteres
1467 richard 13
	//$salt='$1'.'$'.$shuf.'$';
1464 richard 14
	# hash sha-256 > empreinte du mot de passe sur 43 caracteres
1467 richard 15
	$salt='$5'.'$'.$shuf.'$';
1464 richard 16
	# hash sha-512 > empreinte du mot de passe sur 86 caracteres
1467 richard 17
	#$salt='$6'.'$'.$shuf.'$';
325 richard 18
        return crypt($passwd,$salt);
19
}
20
?>