first commit.

This commit is contained in:
kj
2026-10-05 15:08:39 -03:00
commit b7799f9fff
93 changed files with 8966 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace Libs;
/**
* Nonce - DuckBrain
*
* Simple class to create and verify nonces.
*
* @author KJ
* @website https://kj2.me
* @license MIT
*/
class Nonce
{
/**
* Returns a nonce code.
*
* @param string $passphrase
*
* @return string
*/
public static function get(string $passphrase = ''): string
{
return bin2hex(
openssl_encrypt(
time(),
'aes-128-ecb',
$passphrase,
OPENSSL_RAW_DATA
)
);
}
/**
* Verifies a nonce code.
*
* @param string $nonce
* @param string $passphrase
*
* @return bool
*/
public static function check(string $nonce, string $passphrase = ''): bool
{
$decripted = openssl_decrypt(
hex2bin($nonce),
'aes-128-ecb',
$passphrase,
OPENSSL_RAW_DATA
);
return $decripted > (time() - 1800);
}
}