Skip to content

Commit

Permalink
优化 PHP 8.0 兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 14, 2021
1 parent cf2e4fb commit 2a1fbfa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Lib/Encrypt/DSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function signPrivateFromFile($data, $fileName)
throw new \Exception('私钥文件格式错误');
}
openssl_sign($data, $sign, $res, OPENSSL_ALGO_DSS1);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand All @@ -47,7 +47,7 @@ public static function verifyPublicFromFile($data, $fileName, $sign)
throw new \Exception('公钥文件格式错误');
}
$result = openssl_verify($data, $sign, $res, OPENSSL_ALGO_DSS1);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Lib/Encrypt/RSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function signPrivateFromFile($data, $fileName)
throw new \Exception('私钥文件格式错误');
}
openssl_sign($data, $sign, $res, \OPENSSL_ALGO_SHA1);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand All @@ -47,7 +47,7 @@ public static function verifyPublicFromFile($data, $fileName, $sign)
throw new \Exception('公钥文件格式错误');
}
$result = openssl_verify($data, $sign, $res, \OPENSSL_ALGO_SHA1);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand All @@ -63,7 +63,7 @@ public static function encryptPublicFromFile($data, $fileName)
throw new \Exception('公钥文件格式错误');
}
openssl_public_encrypt($data, $result, $res, \OPENSSL_PKCS1_OAEP_PADDING);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Encrypt/RSA2.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function signPrivateFromFile($data, $fileName)
throw new \Exception('私钥文件格式错误');
}
openssl_sign($data, $sign, $res, \OPENSSL_ALGO_SHA256);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand Down Expand Up @@ -63,7 +63,7 @@ public static function verifyPublicFromFile($data, $fileName, $sign)
throw new \Exception('公钥文件格式错误');
}
$result = openssl_verify($data, $sign, $res, \OPENSSL_ALGO_SHA256);
if (PHP_VERSION_ID >= 80000)
if (PHP_VERSION_ID < 80000)
{
openssl_free_key($res);
}
Expand Down

0 comments on commit 2a1fbfa

Please sign in to comment.