Subversion-Projekte lars-tiefland.ci

Revision

Revision 2049 | Revision 2242 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 2049 Revision 2107
Zeile 92... Zeile 92...
92
	 * @param	array	$options
92
	 * @param	array	$options
93
	 * @return	mixed
93
	 * @return	mixed
94
	 */
94
	 */
95
	function password_hash($password, $algo, array $options = array())
95
	function password_hash($password, $algo, array $options = array())
96
	{
96
	{
97
		static $func_override;
97
		static $func_overload;
98
		isset($func_override) OR $func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
98
		isset($func_overload) OR $func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
Zeile 99... Zeile 99...
99
 
99
 
100
		if ($algo !== 1)
100
		if ($algo !== 1)
101
		{
101
		{
102
			trigger_error('password_hash(): Unknown hashing algorithm: '.(int) $algo, E_USER_WARNING);
102
			trigger_error('password_hash(): Unknown hashing algorithm: '.(int) $algo, E_USER_WARNING);
Zeile 107... Zeile 107...
107
		{
107
		{
108
			trigger_error('password_hash(): Invalid bcrypt cost parameter specified: '.(int) $options['cost'], E_USER_WARNING);
108
			trigger_error('password_hash(): Invalid bcrypt cost parameter specified: '.(int) $options['cost'], E_USER_WARNING);
109
			return NULL;
109
			return NULL;
110
		}
110
		}
Zeile 111... Zeile 111...
111
 
111
 
112
		if (isset($options['salt']) && ($saltlen = ($func_override ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))) < 22)
112
		if (isset($options['salt']) && ($saltlen = ($func_overload ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))) < 22)
113
		{
113
		{
114
			trigger_error('password_hash(): Provided salt is too short: '.$saltlen.' expecting 22', E_USER_WARNING);
114
			trigger_error('password_hash(): Provided salt is too short: '.$saltlen.' expecting 22', E_USER_WARNING);
115
			return NULL;
115
			return NULL;
116
		}
116
		}
Zeile 142... Zeile 142...
142
 
142
 
143
				// Try not to waste entropy ...
143
				// Try not to waste entropy ...
Zeile 144... Zeile 144...
144
				is_php('5.4') && stream_set_chunk_size($fp, 16);
144
				is_php('5.4') && stream_set_chunk_size($fp, 16);
145
 
145
 
146
				$options['salt'] = '';
146
				$options['salt'] = '';
147
				for ($read = 0; $read < 16; $read = ($func_override) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
147
				for ($read = 0; $read < 16; $read = ($func_overload) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
148
				{
148
				{
149
					if (($read = fread($fp, 16 - $read)) === FALSE)
149
					if (($read = fread($fp, 16 - $read)) === FALSE)
150
					{
150
					{