1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace refill\tianyi;
- class config
- {
- const ORDER_URL = 'https://api.800.21cn.com/adapter/v1/remote/numberRecognitionUniversal.do';
- const QUERY_URL = 'https://api.800.21cn.com/adapter/v1/remote/numberRecognitionCheck.do';
- const BALANCE_URL = 'http://api.800.21cn.com/fps/queryChargeBalance.do';
- const PARTNER_NO = '105277719';
- const SECRET_KEY = 'USAJuw0zJkmqM0yA';
- const IV = '2859900876319125';
- const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_santi.php";
- const ExtHeaders = ['Content-Type: application/json;charset=UTF-8'];
- const contract_id = '103657';
- const activity_id = '107256';
- const service_code = 'FS0001';
- const Products =
- [
- ];
- private static function decodeBytes($hex)
- {
- $str = '';
- for($i=0;$i<strlen($hex);$i+=2){
- $tmpValue = (((ord($hex[$i]) - ord('a')) & 0xf ) <<4) + ((ord($hex[$i+1])- ord('a')) & 0xf);
- $str .= chr($tmpValue);
- }
- return $str;
- }
- private static function encodeBytes($string)
- {
- $str = '';
- for($i=0;$i<strlen($string);$i++)
- {
- $tmpValue = ord($string[$i]);
- $ch = ($tmpValue >> 4 & 0xf) + ord('a');
- $str .= chr($ch);
- $ch = ($tmpValue & 0xf) + ord('a');
- $str .= chr($ch);
- }
- return $str;
- }
- /**
- * 加密数据
- * @param String $encryptedText 待加密密文
- * @return String
- */
- public static function encrypt(string $encryptedText) {
- $ciphertext = openssl_encrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV);
- return self::encodeBytes($ciphertext);
- }
- /**
- * 解密数据
- * @param String $encryptedText 待解密数据
- * @return String
- */
- public static function decrypt(string $encryptedText) {
- $encryptedText = self::decodeBytes($encryptedText);
- return openssl_decrypt($encryptedText, "AES-128-CBC", self::SECRET_KEY, OPENSSL_RAW_DATA, self::IV);
- }
- }
|