Skip to content

Commit b412ca0

Browse files
author
Tatsuya Sato
committed
Use SecureRandam to generate salt
1 parent beac837 commit b412ca0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/net/ldap/password.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def generate(type, str)
2727
when :sha
2828
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
2929
when :ssha
30-
srand; salt = (rand * 1000).to_i.to_s
30+
srand; salt = SecureRandom.random_bytes(16)
3131
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
3232
else
3333
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"

0 commit comments

Comments
 (0)