- mt_rand: documentation ( source)
- sha1: documentation ( source)
<?php
$pw = 'test123';
$pwInDb = sha1(sha1($pw));
$scramble = mt_rand();
//token
$stage1_hash = sha1($pw);
$token = sha1($scramble . sha1($stage1_hash)) ^ $stage1_hash;
echo $token. "\n";
$stage1_hash = $token ^ sha1($scramble . $pwInDb);
echo '<pre>';
echo sha1($stage1_hash);
echo "\n";
echo $pwInDb;