Class: Ldap::Digest

Inherits:
Object
  • Object
show all
Defined in:
lib/ldap/digest.rb

Class Method Summary collapse

Class Method Details

.sha(secret) ⇒ Object

method from openldap faq which produces the userPassword attribute for the ldap

Parameters:

  • secret

    String the password

Returns:

  • the encoded password



26
27
28
# File 'lib/ldap/digest.rb', line 26

def self.sha(secret)
  ssha(secret, "")
end

.ssha(secret, salt) ⇒ Object

method from openldap faq which produces the userPassword attribute for the ldap

Parameters:

  • secret

    String the password

  • salt

    String the salt for the password digester

Returns:

  • the encoded password/salt



17
18
19
20
# File 'lib/ldap/digest.rb', line 17

def self.ssha(secret, salt)
  (salt.empty? ? "{SHA}": "{SSHA}") +
    Base64.encode64(::Digest::SHA1.digest(secret + salt) + salt).gsub(/\n/, '')
end