# File lib/trocla/util.rb, line 5 def random_str(length=12, charset='default') _charsets = charsets[charset] || charsets['default'] (1..length).collect{|a| _charsets[SecureRandom.random_number(_charsets.size)] }.join.to_s end
# File lib/trocla/util.rb, line 10 def salt(length=8) alphanumeric_size = alphanumeric.size (1..length).collect{|a| alphanumeric[SecureRandom.random_number(alphanumeric_size)] }.join.to_s end
# File lib/trocla/util.rb, line 47 def alphanumeric @alphanumeric ||= ('a'..'z').to_a + ('A'..'Z').to_a + numeric end
# File lib/trocla/util.rb, line 32 def chars @chars ||= shellsafe + special_chars end
# File lib/trocla/util.rb, line 17 def charsets @charsets ||= begin h = { 'default' => chars, 'alphanumeric' => alphanumeric, 'shellsafe' => shellsafe, 'windowssafe' => windowssafe, 'numeric' => numeric, 'hexadecimal' => hexadecimal, 'consolesafe' => consolesafe, } h.each { |k, v| h[k] = v.uniq } end end
# File lib/trocla/util.rb, line 41 def consolesafe @consolesafe ||= alphanumeric + consolesafe_chars end
# File lib/trocla/util.rb, line 62 def consolesafe_chars @consolesafe_chars ||= '+.-,_'.split(//) end
# File lib/trocla/util.rb, line 44 def hexadecimal @hexadecimal ||= numeric + ('a'..'f').to_a end
# File lib/trocla/util.rb, line 50 def numeric @numeric ||= ('0'..'9').to_a end
# File lib/trocla/util.rb, line 35 def shellsafe @shellsafe ||= alphanumeric + shellsafe_chars end
# File lib/trocla/util.rb, line 56 def shellsafe_chars @shellsafe_chars ||= "+%/@=?_.,:".split(//) end
# File lib/trocla/util.rb, line 53 def special_chars @special_chars ||= "*()&![]{}-".split(//) end
# File lib/trocla/util.rb, line 38 def windowssafe @windowssafe ||= alphanumeric + windowssafe_chars end
# File lib/trocla/util.rb, line 59 def windowssafe_chars @windowssafe_chars ||= "+%/@=?_.,".split(//) end