优惠券订单及其他脚本

SecurityTest.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. include './SecurityClient.php';
  3. include './YacCache.php';
  4. $c = new TopClient;
  5. $c->appkey = '576216';
  6. $c->secretKey = 'd1e44cec2f6c8a2c73342595b711decc';
  7. $c->gatewayUrl = 'https://10.218.128.111/router/rest';
  8. $session = '6101701a21788e0e44743d5f1032ccd5276f00ea6a2d9092050695162';
  9. $client = new SecurityClient($c,'S7/xdg4AD7WooWY7+g11qoBpaVsEkonULDJPEiMcXPE=');
  10. $yac = new YacCache;
  11. $client->setCacheClient($yac);
  12. $type = 'phone';
  13. $val = '13834566786';
  14. echo "原文:13834566786".PHP_EOL;
  15. $encryptValue = $client->encrypt($val,$type,$session);
  16. echo "加密后:".$encryptValue.PHP_EOL;
  17. echo "search明文:".$val." -->".$client->search("6786",$type,$session).PHP_EOL;
  18. if($client->isEncryptData($encryptValue,$type))
  19. {
  20. $originalValue = $client->decrypt($encryptValue,$type,$session);
  21. echo "解密后:".$originalValue.PHP_EOL;
  22. }
  23. $originalValue = $client->decrypt('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~','nick',$session);
  24. echo "公钥解密后:".$originalValue.PHP_EOL;
  25. $secArray = array('~YjW+T6rCmKcc0tGqzWIDaQ==~-113~');
  26. $client->decryptBatch($secArray,'nick',$session);
  27. $typeArray = array('normal','nick','receiver_name');
  28. $val2 = '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊看哦【啊啊啊的';
  29. foreach ($typeArray as $type2) {
  30. echo "==============================TOP================================".PHP_EOL;
  31. $encty2 = $client->encrypt($val2,$type2,$session);
  32. echo $type2."|明文:".$val2." ---->密文:".$encty2.PHP_EOL;
  33. if($client->isEncryptData($encty2,$type2))
  34. {
  35. $originalValue = $client->decrypt($encty2,$type2,$session);
  36. echo "解密后:".$originalValue.PHP_EOL;
  37. echo "search明文:".$originalValue." -->".$client->search($originalValue,$type2,$session).PHP_EOL;
  38. }else{
  39. echo "不是加密数据".PHP_EOL;
  40. }
  41. }
  42. $encryptNick = $client->encrypt("xxxuxxxuxxxu","nick");
  43. echo "加密后:".$encryptNick.PHP_EOL;
  44. echo "search明文:xxxuxxxuxxxu -->".$client->search("xxxu","nick").PHP_EOL;
  45. if($client->isEncryptData($encryptNick,"nick"))
  46. {
  47. $originalNick = $client->decryptPublic($encryptNick,"nick");
  48. echo "解密后:".$originalNick.PHP_EOL;
  49. }else{
  50. echo "不是加密数据 ".$encryptNick.PHP_EOL;
  51. }
  52. ?>