Subversion Repositories ALCASAR

Rev

Rev 1467 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
345 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);
12
	# hash md5 > empreinte du mot de passe sur 22 caracteres
13
	//$salt='$1'.'$'.$shuf.'$';
14
	# hash sha-256 > empreinte du mot de passe sur 43 caracteres
15
	$salt='$5'.'$'.$shuf.'$';
16
	# hash sha-512 > empreinte du mot de passe sur 86 caracteres
17
	#$salt='$6'.'$'.$shuf.'$';
345 richard 18
        return crypt($passwd,$salt);
19
}
20
?>