<?php
/**
 * Created by IntelliJ IDEA.
 * User: solu
 * Date: 2019/1/22
 * Time: 2:10 PM
 */

ini_set("display_errors", "On");
set_time_limit(0);
error_reporting(E_ALL & ~E_NOTICE);
require_once realpath(dirname(__FILE__)) . '/../common.php';


//$code = urldecode($code);
//$objAES = new ChatAES();
//$ret = $objAES->encode('test');
//$key = 'W6Lcux7ArPGCBpnWuAyEVK48PrrYX7xW';
//$iv = 'www.duowan.comll';
//$method = 'aes-256-cbc';
//$ret = openssl_encrypt('test', $method, $key, 0, $iv);
//var_dump($ret);exit;

//$ret = $objAES->decode($ret);
//var_dump($ret);exit;

//$ret = Utils::decodePwd('ayZ3diM6Li8mZn81enlpOHMhbjQ1cXB8ank2Njd5M2hldykpYmg2dg==');
//$ret = Utils::encodePwd('问你覅万能福爱我不够二级佛脾胃病反问句佛喷钱机覅偶不敢弗兰克麻烦那U币吧破案发错');

//$en = Utils::decodePwd('6sWt4u2g6abQsenT4te6sKfa4dnl5IzAv+/avvKcuLyI5+Cg5brAsQ==');
//var_dump($en);exit;

$res = "8uhmr7\/GcQoKIJw7\/59CELULWirYXirgcM0UlmCHPcBH1p0zpcANPMU+vWLDb3t2blbWQnSu9IpmsU+5FPt8p00N\/E62jqFwjh0\/5x\/PY80g";
var_dump(Utils::decodeRC4($res));exit;

$source = 'this is message，哈哈哈哈哈，';


$last = '';
$st = microtime(true);
for ($i = 0; $i < 100000; $i++) {
    $source .= $i;
    $e = $objAES->encode($source);
    if ($last == $e) {
        var_dump('error');
    }
    $last = $e;
}
$et = microtime(true);
var_dump('encode done, cost:' . ($et - $st));

$st = microtime(true);
for ($i = 0; $i < 100000; $i++) {
    $s = $objAES->decode($e);
}
$et = microtime(true);
var_dump('encode done, cost:' . ($et - $st));
