From 15e5e9c2be935215de143cb39beae9237fa0044e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sat, 6 Aug 2011 00:59:39 +0200 Subject: JCryption::digest gets trickier --- lib/ayk/jcryption.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/ayk/jcryption.rb b/lib/ayk/jcryption.rb index d498184..a95cadc 100644 --- a/lib/ayk/jcryption.rb +++ b/lib/ayk/jcryption.rb @@ -54,13 +54,9 @@ module JCryption n = passwd.length i = ((n/2)+1)-n%8 i=0 if i<0 - if salt.nil? - m = Digest::MD5.new - m << Time.now.to_s - n = Time.now.to_i%20 - salt = m.to_s[n..n+12] - end - d = Digest::SHA2.new << passwd[0..i]+salt+passwd[i+1..-1] + j = n%20 + salt = Digest::MD5.new << Time.now.to_s if salt.nil? + d = Digest::SHA2.new << passwd[0..i]+salt.to_s[j..j+12]+passwd[i+1..-1] [d,salt] end module_function :digest -- cgit v1.1-2-g2b99