Module: LogStruct::HashUtils

Extended by:
T::Sig
Defined in:
lib/log_struct/hash_utils.rb

Overview

Utility module for hashing sensitive data

Class Method Summary collapse

Class Method Details

.hash_value(value) ⇒ String

Create a hash of a string value for tracing while preserving privacy

Parameters:

  • value (String)

Returns:

  • (String)


14
15
16
17
18
# File 'lib/log_struct/hash_utils.rb', line 14

def hash_value(value)
  salt = LogStruct.config.filters.hash_salt
  length = LogStruct.config.filters.hash_length
  Digest::SHA256.hexdigest("#{salt}#{value}")[0...length] || "error"
end