Compare commits
3
Commits
v0.2.9
...
crypto-v0.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c7eecb97d | ||
|
|
9c80f13748 | ||
|
|
5a28e37998 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "crypto",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"description": "Criptograf\u00eda y segundo factor (Crypto, Nonce, TwoFactorAuthenticator)",
|
||||
"core": {
|
||||
"requires": ">=0.1",
|
||||
|
||||
@@ -41,6 +41,10 @@ class Crypto
|
||||
*/
|
||||
public static function decryptHex(string $data, string $password = PRIVATE_KEY): string
|
||||
{
|
||||
if ($data === '' || !ctype_xdigit($data) || strlen($data) % 2 !== 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return static::decrypt(hex2bin($data), $password);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@ class Nonce
|
||||
*/
|
||||
public static function check(string $nonce, string $passphrase = ''): bool
|
||||
{
|
||||
if ($nonce === '' || !ctype_xdigit($nonce) || strlen($nonce) % 2 !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$decripted = openssl_decrypt(
|
||||
hex2bin($nonce),
|
||||
'aes-128-ecb',
|
||||
|
||||
Reference in New Issue
Block a user