1
- local hmac = ngx .hmac_sha1
2
1
local type = type
3
2
local time = ngx .time
4
3
local concat = table.concat
@@ -7,18 +6,18 @@ local default = {}
7
6
8
7
function default :save (close )
9
8
local i , e , s = self .id , self .expires , self .storage
10
- local k = hmac (self .secret , i .. e )
9
+ local k = self . hmac (self .secret , i .. e )
11
10
local d = self .serializer .serialize (self .data )
12
- local h = hmac (k , concat { i , e , d , self .key })
11
+ local h = self . hmac (k , concat { i , e , d , self .key })
13
12
return s :save (i , e , self .cipher :encrypt (d , k , i , self .key ), h , close )
14
13
end
15
14
16
15
function default :open (cookie )
17
16
local i , e , d , h = self .storage :open (cookie , self .cookie .lifetime )
18
17
if i and e and e > time () and d and h then
19
- local k = hmac (self .secret , i .. e )
18
+ local k = self . hmac (self .secret , i .. e )
20
19
d = self .cipher :decrypt (d , k , i , self .key )
21
- if d and hmac (k , concat { i , e , d , self .key }) == h then
20
+ if d and self . hmac (k , concat { i , e , d , self .key }) == h then
22
21
d = self .serializer .deserialize (d )
23
22
self .id = i
24
23
self .expires = e
0 commit comments