Name: Anonymous 2008-08-19 8:01
$file_id = $db->escape_string(md5_file($file));
$file_id = $db->escape_string(md5_file($file));
define("PASS", "Site wide totally random stuff to use as a salt. Hammer on your keyboard for 30 seconds, please.");
define("passHashingIters", 512);
function passhash($password, $raw = true)
{
$p = str_split(PASS);
$pl = strlen(PASS);
if (passHashingIters > 1) {
for ($i = 0; $i !== passHashingIters - 1; ++$i) {
$password = hash('sha512', $password . $p[$i%$pl], true);
}
}
return hash('sha512', $password, $raw);
}str_split with only one argument displays ignorance of the language.
str_split with one argument does is waste time with a function call that does nothing.
$ php -r 'print_r( str_split( "have a wank" ) );'
Array
(
[0] => h
[1] => a
[2] => v
[3] => e
[4] =>
[5] => a
[6] =>
[7] => w
[8] => a
[9] => n
[10] => k
)
$ php -r 'print_r( is_array( "asd" ) ? "Arrays\n" : "Not arrays\n" );'
Not arrays$ php -r 'foreach( "asd" as $a ) echo( "$a\n" );'
Warning: Invalid argument supplied for foreach() in Command line code on line 1
$ php -r 'foreach( str_split( "asd" ) as $a ) echo( "$a\n" );'
a
s
d~$ php -r '$a = "string"; $a[3] = "u"; echo $a;'
strung
foreach aside, you'd be hard-pressed to find a context where the distinction matters.foreach, as it does in Python. I guess I overestimated PHP again.
md5 returns the hash as a string of hex digits rather than a binary blob.
`
>Not getting 36GET
>2008