Module: GdprAdmin::Anonymizers::InternetAnonymizer

Included in:
Helpers::FieldAnonymizerHelper
Defined in:
lib/gdpr_admin/anonymizers/internet_anonymizer.rb

Instance Method Summary collapse

Instance Method Details

#anonymize_emailObject



6
7
8
# File 'lib/gdpr_admin/anonymizers/internet_anonymizer.rb', line 6

def anonymize_email
  Faker::Internet.email
end

#anonymize_ipObject



14
15
16
# File 'lib/gdpr_admin/anonymizers/internet_anonymizer.rb', line 14

def anonymize_ip
  Faker::Internet.ip_v4_address
end

#anonymize_password(record) ⇒ Object



10
11
12
# File 'lib/gdpr_admin/anonymizers/internet_anonymizer.rb', line 10

def anonymize_password(record)
  record.send(:password_digest, SecureRandom.hex(32))
end

#mask_ip(_record, _field, value) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/gdpr_admin/anonymizers/internet_anonymizer.rb', line 18

def mask_ip(_record, _field, value)
  addr = IPAddr.new(value.to_s)
  return addr.mask(24).to_s if addr.ipv4?

  addr.mask(48).to_s
rescue IPAddr::InvalidAddressError
  value
end