lib/trocla/util.rb in trocla-0.0.7 vs lib/trocla/util.rb in trocla-0.0.8
- old
+ new
@@ -1,13 +1,14 @@
+require 'securerandom'
class Trocla
class Util
class << self
def random_str(length=12)
- (1..length).collect{|a| chars[rand(chars.size)] }.join.to_s
+ (1..length).collect{|a| chars[SecureRandom.random_number(chars.size)] }.join.to_s
end
def salt(length=8)
- (1..length).collect{|a| normal_chars[rand(normal_chars.size)] }.join.to_s
+ (1..length).collect{|a| normal_chars[SecureRandom.random_number(normal_chars.size)] }.join.to_s
end
private
def chars
@chars ||= normal_chars + special_chars