summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/trocla/util.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/trocla/util.rb b/lib/trocla/util.rb
index 78462f5..8e94d0d 100644
--- a/lib/trocla/util.rb
+++ b/lib/trocla/util.rb
@@ -3,12 +3,14 @@ class Trocla
class Util
class << self
def random_str(length=12, charset='default')
- _charsets = charsets[charset]
+ _charsets = charsets[charset] || charsets['default']
+ _charsets_size = _charsets_size
(1..length).collect{|a| _charsets[SecureRandom.random_number(_charsets.size)] }.join.to_s
end
def salt(length=8)
- (1..length).collect{|a| alphanumeric[SecureRandom.random_number(alphanumeric.size)] }.join.to_s
+ alphanumeric_size = alphanumeric.size
+ (1..length).collect{|a| alphanumeric[SecureRandom.random_number(alphanumeric_size)] }.join.to_s
end
private