ZskkApiController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\common\controller;
  3. use app\common\library\BlurUtils;
  4. use app\common\library\Gm;
  5. use think\facade\Config;
  6. class ZskkApiController extends Api
  7. {
  8. protected function initialize(): void
  9. {
  10. BlurUtils::setNotNeedBlur();
  11. }
  12. /**
  13. * $params $data
  14. */
  15. public function makeModelData($data,$mapping): array
  16. {
  17. $info = [];
  18. foreach ($data as $k=>$v)
  19. {
  20. if($info[$mapping[$k]] ?? '')
  21. {
  22. continue;
  23. }
  24. $info[$mapping[$k]] = $v;
  25. }
  26. return $info;
  27. }
  28. public function getDecryptData($data): array
  29. {
  30. $key = 'zLxapoeqWYpoeqWY';
  31. $info = Gm::decrypt($key,$data);
  32. return json_decode(base64_decode($info),true);
  33. }
  34. public function makeEncryptData($data)
  35. {
  36. // $key = Config::get('gm.key');
  37. $key = 'zLxapoeqWYpoeqWY';
  38. $a = json_encode($data);
  39. var_dump($a);
  40. var_dump(base64_encode($a));
  41. $info = Gm::encrypt($key,(base64_encode(json_encode($data))));
  42. var_dump($info);die;
  43. return $info;
  44. }
  45. public function getHeaderToken(): string
  46. {
  47. $header = getallheaders();
  48. $auth = $header['Authorization'];
  49. $data = explode(' ',$auth);
  50. return $data[1];
  51. }
  52. }