class Obfusc::Random

Grab most comon characters and generate a random list of key and value

Constants

ALPHA
DIGIT
SPECIAL

Public Class Methods

generate!() click to toggle source
# File lib/obfusc/random.rb, line 12
def self.generate!
  hash = {}
  randonize!(hash, DIGIT + ALPHA)
  randonize!(hash, SPECIAL)
  hash
end

Private Class Methods

randonize!(memo, source) click to toggle source
# File lib/obfusc/random.rb, line 19
                     def self.randonize!(memo, source)
  source.sort_by { rand }.each do |char|
    list = source - (memo.values & source)
    loop do
      memo[char] = list.sample
      break if list.size <= 1
      break if memo[char] != char
    end
  end
  memo
end