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