summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ayk/jcryption.rb10
1 files 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