Skip to content

Commit

Permalink
Use SecureRandam to generate salt
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsuya Sato committed Jan 6, 2015
1 parent beac837 commit b412ca0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/net/ldap/password.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def generate(type, str)
when :sha
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
when :ssha
srand; salt = (rand * 1000).to_i.to_s
srand; salt = SecureRandom.random_bytes(16)
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
else
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"
Expand Down

0 comments on commit b412ca0

Please sign in to comment.