说明 / 示例
```language
moapi.kamiv2_nema_ml = getWorkPath().."\nema_tkmy.txt";
moapi.kamiv2_nema_tkmy = retFile(moapi.kamiv2_nema_ml);
function moapi:kamiv2_卡密验证(脚本名称,密卡,机器码,appkey)
local _json = {
脚本名称 = 脚本名称;
密卡 = 密卡;
机器码 = 机器码;
nema_tkmy = self.kamiv2_nema_tkmy; -- 防止多开加入的心跳验证 如果脚本老是重启需要保存这个数据
time = os.time();
tkmy = appkey; -- 脚本的加密数据
}
_json.tkmy = MD5(_json.time.._json.tkmy.._json["机器码"].._json["密卡"]);
local _url = string.format("http://%s/kamiv2/API.utf-8?api=卡密验证&nema=%s&tkmy=%s&json=%s",self.IP,self.nema,self.tkmy,jsonLib.encode(_json));
local _retStr = httpGet(_url) or "";
if _retStr == "" then
return false;
end
local _retJson = jsonLib.decode(_retStr) or {};
if _retJson["ret"] == "1" then
self.kamiv2_nema_tkmy = _retJson["nema_tkmy"];
if tonumber(_retJson["xtime"]) > tonumber(_retJson["time"]) then
print("时间",_retJson(_retJson["xtime"]))
return false
end
local tkmy = _retJson["tkmy"];
local tkmytime = _retJson["tkmytime"];
local lmd5 = MD5(tkmytime..appkey.._json["机器码"].._json["密卡"])
if tkmy ~= lmd5 then
print("验证",tkmy ,lmd5)
print(tkmytime,tkmy,_json["机器码"],_json["密卡"])
sleep(1000)
return false
end
if os.time() - tonumber(tkmytime) > 200 then
print("连接超时",os.time() - tonumber(tkmytime))
return false
end
_retJson["余下时间"] = _retJson["余下时间"] or "0";
toast("余下时间:".._retJson["余下时间"].."小时")
print(setFile(self.kamiv2_nema_ml,self.kamiv2_nema_tkmy));
print("余下时间:",_retJson["余下时间"],"小时",self.kamiv2_nema_tkmy)
return true;
elseif _retJson["ret"] == "2" then
toast("卡密激活成功")
return true;
else
print(_retStr)
toast(_retStr)
end
return false
end
function moapi:kamiv2_远程数据(文件目录,数据名称,加密,ctkmy,ml)
local _json = {
ml = 文件目录;
file_nema = 数据名称;
tkmy = ctkmy;
nema_tkmy = 加密; -- 脚本的加密数据
}
local username1 = _json.nema_tkmy.._json.tkmy
_json.tkmy = MD5(username1);
local _url = string.format("http://%s/File/API.utf-8?api=文件数据下载&nema=%s&tkmy=%s&json=%s",self.IP,self.nema,self.tkmy,jsonLib.encode(_json));
if ml == nil then
local _retStr = httpGet(_url) or "";
if _retStr == "" then
return false;
end
return _retStr
end
return downloadFile(_url,ml)
end
```