Mercurial Hosting > luan
changeset 1472:60f6741f000a
base64_encode
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 17 Apr 2020 11:16:38 -0600 |
parents | f5b8c7e1ac82 |
children | 6c6ce14db6a8 |
files | src/luan/host/Util.luan src/luan/modules/Binary.luan |
diffstat | 2 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/host/Util.luan Tue Apr 14 20:20:45 2020 -0600 +++ b/src/luan/host/Util.luan Fri Apr 17 11:16:38 2020 -0600 @@ -9,6 +9,7 @@ local format = String.format or error() local Binary = require "luan:Binary.luan" local bytes = Binary.byte or error() +local base64_encode = Binary.base64_encode or error() local Hosted = require "luan:host/Hosted.luan" local Sql = require "luan:sql/Sql.luan" local database = Sql.database or error() @@ -16,7 +17,6 @@ local logger = Logging.logger "Util" require "java" -local Base64 = require "java:java.util.Base64" local MessageDigest = require "java:java.security.MessageDigest" @@ -29,7 +29,7 @@ local function basic_authentication(dir,password) local sha1 = MessageDigest.getInstance("SHA1").digest(password.getBytes()) - local encoded = Base64.getEncoder().encodeToString(sha1) + local encoded = base64_encode(sha1) local file = Io.schemes.file(dir.."/password.nginx") file.delete() file.write_text("admin:{SHA}"..encoded.."\n")
--- a/src/luan/modules/Binary.luan Tue Apr 14 20:20:45 2020 -0600 +++ b/src/luan/modules/Binary.luan Fri Apr 17 11:16:38 2020 -0600 @@ -6,7 +6,7 @@ local Binary = {} Binary.base64_decode = Base64.getDecoder().decode -Binary.base64_encode = Base64.getEncoder().encode +Binary.base64_encode = Base64.getEncoder().encodeToString Binary.binary = BinaryLuan.binary Binary.byte = BinaryLuan.byte_ Binary.to_string = BinaryLuan.to_string