Class: Deidentify::HashEmail
- Inherits:
-
Object
- Object
- Deidentify::HashEmail
- Defined in:
- lib/deidentify/hash_email.rb
Constant Summary collapse
- MAX_DOMAIN_LENGTH =
63 is the longest domain that is still acceptable for URI::MailTo::EMAILS_REGEXP
63
Class Method Summary collapse
Class Method Details
.call(old_email, length: 255) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/deidentify/hash_email.rb', line 8 def self.call(old_email, length: 255) return old_email unless old_email.present? half_length = (length - 1) / 2 # the -1 is to account for the @ symbol name, domain = old_email.split('@') hashed_name = Deidentify::BaseHash.call(name, length: half_length) hashed_domain = Deidentify::BaseHash.call(domain, length: [half_length, MAX_DOMAIN_LENGTH].min) "#{hashed_name}@#{hashed_domain}" end |