Skip to content

Commit

Permalink
[Minor] Allow to disable hash trimming in maybe_obfuscate_string
Browse files Browse the repository at this point in the history
Don't trim hash if <prefix>_privacy_length is zero.
  • Loading branch information
citrin committed Jul 1, 2019
1 parent 978f879 commit bab9c14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lualib/lua_util.lua
Expand Up @@ -943,7 +943,7 @@ end
-- * <prefix>_privacy = false - subject privacy is off
-- * <prefix>_privacy_alg = 'blake2' - default hash-algorithm to obfuscate subject
-- * <prefix>_privacy_prefix = 'obf' - prefix to show it's obfuscated
-- * <prefix>_privacy_length = 16 - cut the length of the hash
-- * <prefix>_privacy_length = 16 - cut the length of the hash; if 0 or fasle full hash is returned
-- @return obfuscated or validated subject
--]]
Expand All @@ -958,7 +958,7 @@ exports.maybe_obfuscate_string = function(subject, settings, prefix)
local subject_hash = hash.create_specific(hash_alg, subject)
local strip_len = settings[prefix .. '_privacy_length']
if strip_len then
if strip_len and strip_len > 0 then
subject = subject_hash:hex():sub(1, strip_len)
else
subject = subject_hash:hex()
Expand Down

0 comments on commit bab9c14

Please sign in to comment.