Class: Trocla::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/trocla/util.rb

Class Method Summary collapse

Class Method Details

.random_str(length = 12, charset = 'default') ⇒ Object



5
6
7
8
# 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

.salt(length = 8) ⇒ Object



10
11
12
13
# 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