Sha256: e2b0f3fe74c8e6304848c0cc6e4626745e35cd99fdc3b774465501636affb921
Contents?: true
Size: 832 Bytes
Versions: 28
Compression:
Stored size: 832 Bytes
Contents
module NdrSupport # Contains logic for consistently obfuscating names and addresses # using a simple substitution cipher. module Obfuscator extend self # Set default obfuscation seed def setup(seed) @seed = seed end # Obfuscate a name or address, either with the given seed, or default seed def obfuscate(name, seed = nil) rnd = Random.new(seed || @seed) vowels = %w(A E I O U) consonants = ('A'..'Z').to_a - vowels digits = ('0'..'9').to_a dict = Hash[(vowels + consonants + digits).zip(vowels.shuffle(random: rnd) + consonants.shuffle(random: rnd) + digits.shuffle(random: rnd))] name.upcase.split(//).map { |s| dict[s] || s }.join end end end
Version data entries
28 entries across 28 versions & 1 rubygems