function adduser($name, $password, $record = null, $authorisation = 1)
 {
     $hash = phash($password);
     $username = amd5($name);
     if (!is_null($this->db->getRowUH('users', 'name', $username))) {
         return false;
     }
     return $this->db->addRow('users', 'name, password, record, authorisation', 'UNHEX(\'' . $username . '\'), \'' . $hash . '\', \'' . $record . '\', \'' . $authorisation . '\'');
 }
Example #2
0
<?php

function phash($data, $salt, $iterations)
{
    $hash = $data;
    foreach (range(1, $iterations) as $i) {
        $hash = hash('sha256', $hash . md5($i) . $salt);
    }
    return $hash;
}
$key = 'U5rmHIZiTQACvaOOFDym347/lA8K+zgBs6P8R/aYJ9uqf+PGBFmGj563f77LjcMG9Ow6xO2WnxdeqFQX';
$data = ['payload' => 'qxxaevctnn+sedgak7hwltyfwvmg', 'time' => time(), 'hmac' => null];
$firstHash = phash($data['payload'], $data['time'], 10);
$secondHash = phash($key, '', 10);
$data['hmac'] = phash($firstHash, $secondHash, 100);
var_dump($data);