Explorar o código

test mg.base64_encode for Lua

bel %!s(int64=11) %!d(string=hai) anos
pai
achega
9f9a6ffda3
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      test/page4.lua

+ 10 - 0
test/page4.lua

@@ -124,5 +124,15 @@ mg.write("  decoded mg-url:        " .. htmlEscape(dec_url_string) .. "\r\n")
 mg.write("  decoded reference url: " .. htmlEscape(dec_ref_string) .. "\r\n")
 mg.write("\r\n")
 
+-- base64_encode
+mg.write("BASE64 encode/decode test:\r\n")
+raw_string = [[ !"#$%&'()*+,-./0123456789:;<=>?@]]
+mg.write("  original string:  " .. htmlEscape(raw_string) .. "\r\n")
+url_string = mg.base64_encode(raw_string)
+ref_string = "ICEiIyQlJicoKSorLC0uLzAxMjM0NTY3ODk6Ozw9Pj9A" -- from http://www.base64encode.org/
+mg.write("  mg-base64:        " .. htmlEscape(url_string) .. "\r\n")
+mg.write("  reference base64: " .. htmlEscape(ref_string) .. "\r\n")
+
+
 -- end of page
 mg.write("</pre>\r\n</body>\r\n</html>\r\n")