30 lines
786 B
PHP
30 lines
786 B
PHP
<?php
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Models\User;
|
|
|
|
class HashHelper
|
|
{
|
|
protected const string algo = 'sha256';
|
|
public static function getRecordHash(User $user): string
|
|
{
|
|
$fields = AllfieldsUserHelper::get();
|
|
$data = array_map(fn ($item) => $user->$item, $fields);
|
|
$dataInLine = implode($data);
|
|
// dd($data);
|
|
return hash(self::algo, $dataInLine);
|
|
}
|
|
|
|
public static function getApiHash($infoOfStudent): string
|
|
{
|
|
// dd($infoOfStudent);
|
|
$fields = AllfieldsUserHelper::get();
|
|
$data = array_map(fn ($item) => $infoOfStudent[$item], $fields);
|
|
// dd($data);
|
|
$dataInLine = implode($data);
|
|
// dd($dataInLine);
|
|
return hash(self::algo, $dataInLine);
|
|
}
|
|
}
|