-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathac.lua
More file actions
62 lines (46 loc) · 1.49 KB
/
ac.lua
File metadata and controls
62 lines (46 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function mixAccessToken(ac,ts,cmd)
if ac and string.len(ac)>0 then
local s1 = string.sub(ac,1,5)
local s2 = string.sub(ac,6,10)
local s3 = string.sub(ac,11,string.len(ac))
local base64 = require "lib.base64"
local newAc = base64.Encrypt(s2..ts..s1..cmd..s3)
if string.len(newAc)>60 then
newAc=string.sub(newAc,10,59)
else
newAc = string.sub(newAc,2,string.len(newAc))
end
newAc = string.gsub(newAc,ts%9,"")
return newAc
end
end
function getUserOldZid(uid)
return math.floor(uid/1000000)
end
function createAccessToken(uid,loginTs,isSet)
uid = uid or 0
if not loginTs then
loginTs = getClientTs()
end
local oldzid = getUserOldZid(uid)
--local secretkey = getConfig("baseCfg.SECRETKEY")
local secretkey = "111"
local baseString = uid .. "_" .. secretkey .. "_" .. loginTs .. "_" ..oldzid
local sha1 = require "lib.sha1"
local base64 = require "lib.base64"
local token = sha1(baseString)
token = base64.Encrypt(token)
-- if PLATFORM=="test" or PLATFORM=="cn_wx" then
-- token = mixAccessToken(token,getClientTs(),getCmd())
-- end
return token, loginTs
end
local ac = "222=="
local ts = 1566998027
print(ts%9)
--print(mixAccessToken(ac, ts, "user.login"))
local getClientTs = 1566998027
local ac = createAccessToken(386019695,1566998028)
mixtoken = mixAccessToken(ac,getClientTs,"user.login")
print(ac)
print(mixtoken)