Skip to content

Commit a20fbb1

Browse files
committed
resty.aes: minor coding style fixes.
1 parent ca4086c commit a20fbb1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/resty/aes.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,15 @@ int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, const unsigned char
8686
local ctx_ptr_type = ffi.typeof("EVP_CIPHER_CTX[1]")
8787

8888
hash = {
89-
md5 = C.EVP_md5(),
90-
sha1 = C.EVP_sha1(),
91-
sha224 = C.EVP_sha224(),
92-
sha256 = C.EVP_sha256(),
93-
sha384 = C.EVP_sha384(),
94-
sha512 = C.EVP_sha512()
89+
md5 = C.EVP_md5(),
90+
sha1 = C.EVP_sha1(),
91+
sha224 = C.EVP_sha224(),
92+
sha256 = C.EVP_sha256(),
93+
sha384 = C.EVP_sha384(),
94+
sha512 = C.EVP_sha512()
9595
}
9696

97+
9798
function cipher(size, _cipher)
9899
local _size = size or 128
99100
local _cipher = _cipher or "cbc"
@@ -105,6 +106,7 @@ function cipher(size, _cipher)
105106
end
106107
end
107108

109+
108110
function new(self, key, salt, _cipher, _hash, hash_rounds)
109111
local encrypt_ctx = ffi_new(ctx_ptr_type)
110112
local decrypt_ctx = ffi_new(ctx_ptr_type)
@@ -162,6 +164,7 @@ function new(self, key, salt, _cipher, _hash, hash_rounds)
162164
}, mt)
163165
end
164166

167+
165168
function encrypt(self, s)
166169
local s_len = #s
167170
local max_len = s_len + 16
@@ -185,6 +188,7 @@ function encrypt(self, s)
185188
return ffi_str(buf, out_len[0] + tmp_len[0])
186189
end
187190

191+
188192
function decrypt(self, s)
189193
local s_len = #s
190194
local buf = ffi_new("unsigned char[?]", s_len)
@@ -207,8 +211,10 @@ function decrypt(self, s)
207211
return ffi_str(buf, out_len[0] + tmp_len[0])
208212
end
209213

214+
210215
-- to prevent use of casual module global variables
211216
getmetatable(resty.aes).__newindex = function (table, key, val)
212217
error('attempt to write to undeclared variable "' .. key .. '": '
213218
.. debug.traceback())
214219
end
220+

0 commit comments

Comments
 (0)