aboutsummaryrefslogtreecommitdiffstats
path: root/server/resty/session/encoders/base64.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/resty/session/encoders/base64.lua')
-rw-r--r--server/resty/session/encoders/base64.lua39
1 files changed, 0 insertions, 39 deletions
diff --git a/server/resty/session/encoders/base64.lua b/server/resty/session/encoders/base64.lua
deleted file mode 100644
index ddaf4e8..0000000
--- a/server/resty/session/encoders/base64.lua
+++ /dev/null
@@ -1,39 +0,0 @@
-local encode_base64 = ngx.encode_base64
-local decode_base64 = ngx.decode_base64
-
-local gsub = string.gsub
-
-local ENCODE_CHARS = {
- ["+"] = "-",
- ["/"] = "_",
-}
-
-local DECODE_CHARS = {
- ["-"] = "+",
- ["_"] = "/",
-}
-
-local encoder = {}
-
-function encoder.encode(value)
- if not value then
- return nil, "unable to base64 encode value"
- end
-
- local encoded = encode_base64(value, true)
- if not encoded then
- return nil, "unable to base64 encode value"
- end
-
- return gsub(encoded, "[+/]", ENCODE_CHARS)
-end
-
-function encoder.decode(value)
- if not value then
- return nil, "unable to base64 decode value"
- end
-
- return decode_base64((gsub(value, "[-_]", DECODE_CHARS)))
-end
-
-return encoder