Comparison

plugins/mod_auth_internal_hashed.lua @ 6707:06cdd4afaaf9

mod_auth_internal_hashed: Use util.hex
author Kim Alvefur <zash@zash.se>
date Mon, 18 May 2015 21:00:41 +0200
parent 6019:e9147a16059d
child 8055:b08d9295f036
comparison
equal deleted inserted replaced
6706:60c692828cf6 6707:06cdd4afaaf9
11 11
12 local getAuthenticationDatabaseSHA1 = require "util.sasl.scram".getAuthenticationDatabaseSHA1; 12 local getAuthenticationDatabaseSHA1 = require "util.sasl.scram".getAuthenticationDatabaseSHA1;
13 local usermanager = require "core.usermanager"; 13 local usermanager = require "core.usermanager";
14 local generate_uuid = require "util.uuid".generate; 14 local generate_uuid = require "util.uuid".generate;
15 local new_sasl = require "util.sasl".new; 15 local new_sasl = require "util.sasl".new;
16 local hex = require"util.hex";
17 local to_hex, from_hex = hex.to, hex.from;
16 18
17 local log = module._log; 19 local log = module._log;
18 local host = module.host; 20 local host = module.host;
19 21
20 local accounts = module:open_store("accounts"); 22 local accounts = module:open_store("accounts");
21 23
22 local to_hex;
23 do
24 local function replace_byte_with_hex(byte)
25 return ("%02x"):format(byte:byte());
26 end
27 function to_hex(binary_string)
28 return binary_string:gsub(".", replace_byte_with_hex);
29 end
30 end
31
32 local from_hex;
33 do
34 local function replace_hex_with_byte(hex)
35 return string.char(tonumber(hex, 16));
36 end
37 function from_hex(hex_string)
38 return hex_string:gsub("..", replace_hex_with_byte);
39 end
40 end
41 24
42 25
43 -- Default; can be set per-user 26 -- Default; can be set per-user
44 local default_iteration_count = 4096; 27 local default_iteration_count = 4096;
45 28