CheckTicket.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * User Julyssn
  5. * Date 2022/11/16 16:52
  6. */
  7. namespace utils;
  8. use Exception;
  9. use think\facade\Config;
  10. class CheckTicket
  11. {
  12. /**
  13. * @param $ticket
  14. * @return false|string|array
  15. */
  16. public static function check($ticket)
  17. {
  18. Config::set([
  19. 'public_key' => "-----BEGIN PUBLIC KEY-----
  20. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv9Tc4Ap1zvbUKSiz7kQ3
  21. wAvb4mrw4zAgViNzOVUkDZwqPTmx2pzPcUpNrh6qTX4JMwoTDRsu96M2a9DYv8iH
  22. qjzU0yw3BfJFC4TZNVYCqD8ULVdiMutZeiAfpkx5jGjLGGXqgVFleQ8nmEE5yFdl
  23. WUTyXjkfCENPdxeiBEp7aqqfKLv3U3t9OssoEYZYSpc+iZbSCyD9kIg8jxFTE2I2
  24. VFl+9ec0Hl9k7R9CIXaO011oI9RVoauZNxgtUXauvU7GGQjsVHEcBj8qvDhLWVA7
  25. MrKA9tkKDwyXDlHdBNtLAfwVgn7d7NkveqI8Qh2k7tXZhoP2txE9AiO9lIf7G4Pa
  26. RQIDAQAB
  27. -----END PUBLIC KEY-----"
  28. ], 'cipher');
  29. $rsa = new Rsa(new Config());
  30. try {
  31. $data = $rsa->publicDecrypt($ticket);
  32. if ($data) {
  33. return $data;
  34. } else {
  35. return false;
  36. }
  37. } catch (Exception $e) {
  38. return false;
  39. }
  40. }
  41. }