Last active
April 22, 2021 15:05
-
-
Save ZahidRasheed/ec08e9fcebe3671cbb3f4d8a2e7109da to your computer and use it in GitHub Desktop.
This file contains 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 | |
function getFallbackToken() | |
{ | |
$date = new DateTime(); | |
$date->add(new DateInterval('PT4H')); | |
echo $date->format('Y-m-d H:i:s'); | |
$expires = $date->format(DateTime::ATOM); | |
$content = json_encode([ | |
'expires' => $expires, | |
'ip' => "127.0.0.1", | |
'userid' => rand(10000, 99999), | |
]); | |
$cipher = new AES(AES::MODE_ECB); | |
$cipher->setKey(env('FALLBACK_AES_KEY', 'RandomStringMadeFrom32Characters')); | |
$token = base64_encode($cipher->encrypt($content)); | |
$res = array( | |
'token' => $token, | |
'expires' => $expires, | |
); | |
return $res; | |
} | |
getFallbackToken(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment