Subversion Repositories ALCASAR

Rev

Rev 386 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 386 Rev 1467
Line 1... Line 1...
1
<?php
1
<?php
2
function da_encrypt()
2
function da_encrypt()
3
{
3
{
4
	$numargs=func_num_args();
4
	$numargs=func_num_args();
5
	$passwd=func_get_arg(0);
5
	$passwd=func_get_arg(0);
-
 
6
	# set the salt and the algorithm
-
 
7
	$shuf = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"),0,8);
-
 
8
	# hash md5 > empreinte du mot de passe sur 22 caracteres
-
 
9
	//$salt='$1'.'$'.$shuf.'$';
6
	# calcul d'un salt pour forcer le chiffrement en MD5 au lieu de blowfish par defaut dans php version mdva > 2007.1
10
	# hash sha-256 > empreinte du mot de passe sur 43 caracteres
7
	$salt='$1$passwd$';
11
	$salt='$5'.'$'.$shuf.'$';
-
 
12
	# hash sha-512 > empreinte du mot de passe sur 86 caracteres
8
	if ($numargs == 2){
13
	#$salt='$6'.'$'.$shuf.'$';
-
 
14
	if ($numargs == 2){ //only to test and change password (keep the old algorythm and salt)
9
		$salt=func_get_arg(1);
15
		$salt=func_get_arg(1);
10
		return crypt($passwd,$salt);
16
		return crypt($passwd,$salt);
11
	}
17
	}
12
        return crypt($passwd,$salt);
18
        return crypt($passwd,$salt);
13
}
19
}