Last active
June 26, 2025 17:04
-
-
Save Kcko/1720f32ea5f94387b7c2d20ed504d8fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Pro hesla uživatelů | |
$hashedPassword = password_hash($userPassword, PASSWORD_DEFAULT); | |
if (password_verify($inputPassword, $hashedPassword)) { | |
// přihlášen | |
} | |
// Pro bearer tokeny | |
$token = hash_hmac('sha256', $windowStart, 'secret'); | |
if (hash_equals($token, $receivedToken)) { | |
// autorizován | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$currentTime = time(); | |
$timeWindow = 500; // token expiration | |
$expectedToken = hash_hmac('sha256', $currentTime - ($currentTime % $timeWindow), 'OUR_ANY_SECRET'); | |
// echo hash_equals($expectedToken, $anyTokenFromGetorPost); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment