简单的时间加解密函数,转自恶猫博客
import console; var currentUser = "523123123"; math.randomize(); function encryptDate( dateTick, currentUser ){ var cryptNum = tonumber(currentUser) * tonumber(string.left(currentUser,1)); //取加密日期 var rstr=string.split("ABCDEFGHIJKLMNOPQRSTUVWXYZ",""); var tick = tostring( dateTick + cryptNum); var tb = {}; for(i=1;#tick;1){ table.push( tb, rstr[math.random(1, #rstr)] ++ tick[[i]] ); } var tickStr = string.reverse(string.join(tb)); return tickStr; } function decryptDate( cryptStr, currentUser ){ var cryptNum = tonumber(currentUser) * tonumber(string.left(currentUser,1)); num = string.reverse( string.replace(cryptStr,"[A-Z]+","") ); num = tonumber( num ) - cryptNum ; return num, time(num); } var jiami = encryptDate( 1468587705, currentUser ) console.log( jiami ); var jiemi = decryptDate( jiami, currentUser ) console.log( jiemi ); console.pause(true);
虽然aardio做网站也可以,但php的源码更多。自己把上面的源码翻译一份php的。方便aardio和php互通。
//解密时间戳 function decryptDate( $cryptStr, $currentUser ){ $cryptNum = floatval($currentUser)* floatval(substr ($currentUser, 0,1)); $str = preg_replace("/[A-Z]+/",'',$cryptStr); $strtab = array_reverse(str_split($str)); $str = implode("",$strtab); return (floatval($str)-$cryptNum ); } //加密时间戳 function encryptDate( $dateTick, $currentUser ){ $cryptNum = floatval($currentUser)* floatval(substr ($currentUser, 0,1)); //取加密日期 $rstr = str_split("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); $tick = strval( $dateTick + $cryptNum); $tab = []; $tick = str_split($tick); for($i=0;$i<count($tick);$i++){ $k = rand(0,(count($rstr)-1)); $str = $rstr[$k].$tick[$i]; array_push($tab,$str); } $tickStr = array_reverse($tab); return implode("",$tickStr); }