summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2011-08-05 23:27:52 +0200
committermh <mh@immerda.ch>2011-08-05 23:27:52 +0200
commit02d0ab7cb6f9490e8846c0cb703a9efdb9e6518f (patch)
treec793aed5113a72e774087d6286ac62ed0b958c75 /lib
parent1d5f20953d6a4bf6de8dab1d915b4d252eb4a790 (diff)
salt should not really containt special characters
Diffstat (limited to 'lib')
-rw-r--r--lib/trocla/util.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/trocla/util.rb b/lib/trocla/util.rb
index 468206d..5bca8f1 100644
--- a/lib/trocla/util.rb
+++ b/lib/trocla/util.rb
@@ -4,11 +4,21 @@ class Trocla
def random_str(length=12)
(1..length).collect{|a| chars[rand(chars.size)] }.join.to_s
end
-
+
+ def salt(length=8)
+ (1..length).collect{|a| normal_chars[rand(normal_chars.size)] }.join.to_s
+ end
+
private
def chars
- @chars ||= (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a) + "+*%/()@&=?![]{}-_.,;:<>".split(//)
+ @chars ||= normal_chars + special_chars
+ end
+ def normal_chars
+ @normal_chars ||= ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
+ end
+ def special_chars
+ @special_chars ||= "+*%/()@&=?![]{}-_.,;:<>".split(//)
end
end
end
-end \ No newline at end of file
+end