Last active
August 29, 2015 14:02
-
-
Save rangercyh/5d87f2c13d48f521ec99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--激活码生成代码 1.0 beta版 | |
--creator: caiyiheng | |
--需要和这次排重的前缀: | |
--PT,VP,WB,WL,SE,WY,TX,XX,GM,DG,DH,RA,RB,RC,EX,XL,GP,GZ,PP,PZ,HD,HG,WX,AW,B1,B2,B3 | |
local new_code = { | |
[73] = { "备用1.txt", "XX", 10000000 }, | |
} | |
KEY_LENTH = 14 --激活码长度,这个长度加上上面前缀为最终激活码 | |
CODE_PASS_TIME_STR = ",%d,2015-05-09 23:59:59,0\n" --激活码过期时间 | |
function GenerateChickenAndHorse() | |
local szRandomChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
local nStrLen = string.len(szRandomChar) | |
local szRet = "" | |
for i = 1, KEY_LENTH do | |
local nPos = math.random(nStrLen) | |
local szCode = string.sub(szRandomChar, nPos, nPos) | |
szRet = szRet..szCode | |
end | |
return szRet | |
end | |
function IterGener(tbOldKeys, hFile, nID, szPrefix, nNum) | |
local nRealNum = 0 | |
while nRealNum < nNum do | |
local szKey = GenerateChickenAndHorse() | |
if (tbOldKeys[szKey] == nil) then | |
hFile:write(szPrefix..szKey..string.format(CODE_PASS_TIME_STR, nID)) | |
nRealNum = nRealNum + 1 | |
tbOldKeys[szKey] = true; | |
end | |
end | |
end | |
function NewKey() | |
local tbOldKeys = {} | |
local tstart = os.time() | |
for nID, tbInfo in pairs(new_code) do | |
local t1 = os.time() | |
local hFile = io.open(tbInfo[1], "w") | |
IterGener(tbOldKeys, hFile, nID, tbInfo[2], tbInfo[3]) | |
hFile:close() | |
print(tbInfo[3].."\tOK".."\t耗时:", os.time() - t1, tbInfo[1]) | |
end | |
print("总耗时:", os.time() - tstart) | |
end | |
NewKey() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
生成自带前缀的激活码