# HG changeset patch # User Kim Alvefur # Date 1431975641 -7200 # Node ID 06cdd4afaaf97b19ac6768d3db2aaec76b1413e7 # Parent 60c692828cf60ab34699df23b47491d1fd3e3e77 mod_auth_internal_hashed: Use util.hex diff -r 60c692828cf6 -r 06cdd4afaaf9 plugins/mod_auth_internal_hashed.lua --- a/plugins/mod_auth_internal_hashed.lua Mon May 18 20:50:50 2015 +0200 +++ b/plugins/mod_auth_internal_hashed.lua Mon May 18 21:00:41 2015 +0200 @@ -13,31 +13,14 @@ local usermanager = require "core.usermanager"; local generate_uuid = require "util.uuid".generate; local new_sasl = require "util.sasl".new; +local hex = require"util.hex"; +local to_hex, from_hex = hex.to, hex.from; local log = module._log; local host = module.host; local accounts = module:open_store("accounts"); -local to_hex; -do - local function replace_byte_with_hex(byte) - return ("%02x"):format(byte:byte()); - end - function to_hex(binary_string) - return binary_string:gsub(".", replace_byte_with_hex); - end -end - -local from_hex; -do - local function replace_hex_with_byte(hex) - return string.char(tonumber(hex, 16)); - end - function from_hex(hex_string) - return hex_string:gsub("..", replace_hex_with_byte); - end -end -- Default; can be set per-user