SHA1.Class.php 565 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace JinDouYun\Controller;
  3. /**
  4. * PHP7.1及其之上版本的回调加解密类库
  5. * 该版本依赖openssl_encrypt方法加解密,注意版本依赖 (PHP 5 >= 5.3.0, PHP 7)
  6. */
  7. class SHA1
  8. {
  9. public function getSHA1($token, $timestamp, $nonce, $encrypt_msg)
  10. {
  11. try {
  12. $array = array($encrypt_msg, $token, $timestamp, $nonce);
  13. sort($array, SORT_STRING);
  14. $str = implode($array);
  15. return array(ErrorCode::$OK, sha1($str));
  16. } catch (\Exception $e) {
  17. print $e . "\n";
  18. return array(ErrorCode::$ComputeSignatureError, null);
  19. }
  20. }
  21. }
  22. ?>