以编程方式登录 traccar php?

Programmatically login traccar php?

我已经通过这个 Link 实现了登录 traccar,但为什么散列不一样并且总是 return 错误?

代码:

$email = $this->param['email'];
    $password = $this->param['password'];
    $qselect ='SELECT u.id as uid, u.name as uname, u.hashedPassword as hashed,u.salt,u.admin 
                FROM users u INNER JOIN users us ON us.id = u.id WHERE us.email = "'.$email.'"'; 
    $row = $this->mysqli->query($qselect)->fetch_array();
    $key = $this->hexToStr(trim($row['salt']));
    $hashed = hash_pbkdf2("sha1",$password, $key,1000,24,true); 
    echo $this->strToHex($hashed)."---".$row['hashed']."-----".$row['salt'];
    var_dump(trim($this->strToHex($hashed))==trim($row['hashed']));
    exit();              
    if ($this->strToHex($hashed)==$row['hashed']){
        $_SESSION['loginstate'] = 1;
        echo 1;
    }else{
        echo 0;
    }

the result is D33DCA55ABD4CC5BC76F2BC0B4E63FE2C6F61F4C1EF2D47---D33DCA55ABD4CC5BC76F2BC0B4E603FE2C6F61F4C1EF2D47-----000000000000000000000000000000000000000000000000bool(false)

正如您所看到的,唯一不同的是当来自 db 的结果哈希为 63 而来自生成 hash_pbkdf2 的结果哈希为 603 时,唯一的不同是一个数字,不同的是零,我可以解决什么问题吗?

通过此代码解决

while($row = $q->fetch_array()){
        $data = $password;
        $key = hex2bin($row['salt']);
        $hashed = hash_pbkdf2('sha1',$data, $key,1000,24,true);

        echo bin2hex($hashed)."---".$row['hashed'];
        var_dump(strtoupper(bin2hex($hashed))==$row['hashed']);

        if (strtoupper(bin2hex($hashed))==$row['hashed']){
                        //session_start();
                        //$_SESSION['email'] = $email;
                    $_SESSION['hashedpassword'] = $password; 
                    header('location:page.php');
                      }
    }

use bin2hex and hex2bin with hashed upper