Skip to content

Commit e811ed8

Browse files
author
Michael Schaarschmidt
committed
Merge remote-tracking branch 'origin/master'
2 parents 51a7ea4 + c0a6e1e commit e811ed8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/net/ldap/password.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'digest/sha1'
33
require 'digest/md5'
44
require 'base64'
5+
require 'securerandom'
56

67
class Net::LDAP::Password
78
class << self
@@ -26,7 +27,7 @@ def generate(type, str)
2627
when :sha
2728
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
2829
when :ssha
29-
srand; salt = (rand * 1000).to_i.to_s
30+
salt = SecureRandom.random_bytes(16)
3031
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
3132
else
3233
raise Net::LDAP::LdapError, "Unsupported password-hash type (#{type})"

0 commit comments

Comments
 (0)