aes-benchmark.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Created by IntelliJ IDEA.
  4. * User: solu
  5. * Date: 2019/1/22
  6. * Time: 2:10 PM
  7. */
  8. ini_set("display_errors", "On");
  9. set_time_limit(0);
  10. error_reporting(E_ALL & ~E_NOTICE);
  11. require_once realpath(dirname(__FILE__)) . '/../common.php';
  12. //$code = urldecode($code);
  13. //$objAES = new ChatAES();
  14. //$ret = $objAES->encode('test');
  15. //$key = 'W6Lcux7ArPGCBpnWuAyEVK48PrrYX7xW';
  16. //$iv = 'www.duowan.comll';
  17. //$method = 'aes-256-cbc';
  18. //$ret = openssl_encrypt('test', $method, $key, 0, $iv);
  19. //var_dump($ret);exit;
  20. //$ret = $objAES->decode($ret);
  21. //var_dump($ret);exit;
  22. //$ret = Utils::decodePwd('ayZ3diM6Li8mZn81enlpOHMhbjQ1cXB8ank2Njd5M2hldykpYmg2dg==');
  23. //$ret = Utils::encodePwd('问你覅万能福爱我不够二级佛脾胃病反问句佛喷钱机覅偶不敢弗兰克麻烦那U币吧破案发错');
  24. //$en = Utils::decodePwd('6sWt4u2g6abQsenT4te6sKfa4dnl5IzAv+/avvKcuLyI5+Cg5brAsQ==');
  25. //var_dump($en);exit;
  26. $res = "8uhmr7\/GcQoKIJw7\/59CELULWirYXirgcM0UlmCHPcBH1p0zpcANPMU+vWLDb3t2blbWQnSu9IpmsU+5FPt8p00N\/E62jqFwjh0\/5x\/PY80g";
  27. var_dump(Utils::decodeRC4($res));exit;
  28. $source = 'this is message,哈哈哈哈哈,';
  29. $last = '';
  30. $st = microtime(true);
  31. for ($i = 0; $i < 100000; $i++) {
  32. $source .= $i;
  33. $e = $objAES->encode($source);
  34. if ($last == $e) {
  35. var_dump('error');
  36. }
  37. $last = $e;
  38. }
  39. $et = microtime(true);
  40. var_dump('encode done, cost:' . ($et - $st));
  41. $st = microtime(true);
  42. for ($i = 0; $i < 100000; $i++) {
  43. $s = $objAES->decode($e);
  44. }
  45. $et = microtime(true);
  46. var_dump('encode done, cost:' . ($et - $st));