- var_dump: documentation ( source)
- time: documentation ( source)
- mt_rand: documentation ( source)
- sha1: documentation ( source)
- hash: documentation ( source)
- in_array: documentation ( source)
- hash_algos: documentation ( source)
<?php
$token = mt_rand() . mt_rand() . mt_rand() . mt_rand();
$_SESSION['token_timestamp'] = time();
$hash_algos = hash_algos();
if (in_array('sha512', $hash_algos)) {
$token = hash('sha512', $token, false);
} else {
$token = sha1($token, false);
}
var_dump($token);