config.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace refill\tianyi;
  3. class config
  4. {
  5. const ORDER_URL = 'https://api.800.21cn.com/adapter/v1/remote/numberRecognitionUniversal.do';
  6. const QUERY_URL = 'https://api.800.21cn.com/adapter/v1/remote/numberRecognitionCheck.do';
  7. const BALANCE_URL = 'http://api.800.21cn.com/fps/queryChargeBalance.do';
  8. const PARTNER_NO = '105277719';
  9. const SECRET_KEY = 'USAJuw0zJkmqM0yA';
  10. const IV = '2859900876319125';
  11. const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_santi.php";
  12. const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
  13. const contract_id = '103657';
  14. const activity_id = '107256';
  15. const service_code = 'FS0001';
  16. const Products =
  17. [
  18. ];
  19. private static function decodeBytes($hex)
  20. {
  21. $str = '';
  22. for($i=0;$i<strlen($hex);$i+=2){
  23. $tmpValue = (((ord($hex[$i]) - ord('a')) & 0xf ) <<4) + ((ord($hex[$i+1])- ord('a')) & 0xf);
  24. $str .= chr($tmpValue);
  25. }
  26. return $str;
  27. }
  28. private static function encodeBytes($string)
  29. {
  30. $str = '';
  31. for($i=0;$i<strlen($string);$i++)
  32. {
  33. $tmpValue = ord($string[$i]);
  34. $ch = ($tmpValue >> 4 & 0xf) + ord('a');
  35. $str .= chr($ch);
  36. $ch = ($tmpValue & 0xf) + ord('a');
  37. $str .= chr($ch);
  38. }
  39. return $str;
  40. }
  41. /**
  42. * 加密数据
  43. * @param String $encryptedText 待加密密文
  44. * @return String
  45. */
  46. public static function encrypt(string $encryptedText) {
  47. $ciphertext = openssl_encrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV);
  48. return self::encodeBytes($ciphertext);
  49. }
  50. /**
  51. * 解密数据
  52. * @param String $encryptedText 待解密数据
  53. * @return String
  54. */
  55. public static function decrypt(string $encryptedText) {
  56. $encryptedText = self::decodeBytes($encryptedText);
  57. return openssl_decrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV);
  58. }
  59. }