lib/salty.rb in salty-0.0.7 vs lib/salty.rb in salty-0.1.0

- old
+ new

@@ -1,26 +1,18 @@ -require 'digest/sha1' +require 'pbkdf2' module Salty SALT_LENGTH=30 ALPHA = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a - def Salty.hash_fn(str) - sha512 = Digest::SHA2.new(512) - sha512.hexdigest(str) - end - def Salty.generate_salt (1..SALT_LENGTH).map{ALPHA.sample}.join end def Salty.salted_hash(str,salt) - res = str - 100.times do - res = hash_fn(res+salt) - end - res + pbkdf2 = PBKDF2.new(:password => str, :salt => salt, :iterations => 1000) + pbkdf2.hex_string end def Salty.hash(str) salt = generate_salt