diff --git a/newbiecontest/prog/crypto/crypto.lua b/newbiecontest/prog/crypto/crypto.lua index fa9aa95..7d3e66a 100755 --- a/newbiecontest/prog/crypto/crypto.lua +++ b/newbiecontest/prog/crypto/crypto.lua @@ -33,7 +33,7 @@ function extract_message(cookie_name, cookie_value, url) -- add the SMF cookie to the header local headers = { - ["Cookie"] = cookie_name .. "=" .. cookie_value; + ["Cookie"] = cookie_name .. "=" .. cookie_value } -- request @@ -46,39 +46,39 @@ function extract_message(cookie_name, cookie_value, url) string_r = table.concat(t) -- extract message and key - message = string.match(string_r, '\'([a-z]+)\''); - key = string.match(string_r, '\'([0-9]+)\''); + message = string.match(string_r, '\'([a-z]+)\'') + key = string.match(string_r, '\'([0-9]+)\'') - return message, key; + return message, key end -- decrypt function decrypt(message, key) - i = 0; - char_code = 0; + i = 0 + char_code = 0 -- create the local table containing the solution - local r = {}; + local r = {} -- for each byte of the message for i = 1, string.len(message), i + 1 do -- extract the char code - char_code = string.byte(message, i); + char_code = string.byte(message, i) -- if it goes behind the "a" move to "z" if (char_code - key < string.byte("a")) then -- here goes the barbary... r[i] = string.char((string.byte("z")) - (key - (char_code - - string.byte("a") - 1))); + string.byte("a") - 1))) -- if it's not, just do it else - r[i] = string.char(char_code - key); + r[i] = string.char(char_code - key) end end - return table.concat(r); + return table.concat(r) end @@ -93,7 +93,7 @@ function decrypt(message, key) -- add the SMF cookie to the header local headers = { - ["Cookie"] = cookie_name .. "=" .. cookie_value; + ["Cookie"] = cookie_name .. "=" .. cookie_value } -- send the reply @@ -102,7 +102,7 @@ function decrypt(message, key) sink = ltn12.sink.table(t) } - return table.concat(t); -- return the token + return table.concat(t) -- return the token end @@ -120,9 +120,9 @@ function decrypt(message, key) cookie_value, cookie_name = extract_cookie(conn) - message, key = extract_message(cookie_name, cookie_value, arg[2]); + message, key = extract_message(cookie_name, cookie_value, arg[2]) - r = decrypt(message, key); + r = decrypt(message, key) token = send_response(r, arg[3])