From 02d0ab7cb6f9490e8846c0cb703a9efdb9e6518f Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 5 Aug 2011 23:27:52 +0200 Subject: salt should not really containt special characters --- lib/trocla/util.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3