Sha256: 9d332d093961a09f37067e717e05627a5ba5fec6954640dd388262e5d89b13f5

Contents?: true

Size: 707 Bytes

Versions: 7

Compression:

Stored size: 707 Bytes

Contents

module Ldap
  class Digest
    # method from openldap faq which produces the userPassword attribute
    # for the ldap
    # @param secret String the password
    # @param salt String the salt for the password digester
    # @return the encoded password/salt
    def self.ssha(secret, salt)
      require 'sha1' 
      require 'base64' 
      (salt.empty? ? "{SHA}": "{SSHA}") +  
        Base64.encode64(::Digest::SHA1.digest(secret + salt) + salt).gsub(/\n/, '')
    end

    # method from openldap faq which produces the userPassword attribute
    # for the ldap
    # @param secret String the password
    # @return the encoded password
    def self.sha(secret)
      ssha(secret, "")
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dm-ldap-adapter-0.3.5 lib/ldap/digest.rb
dm-ldap-adapter-0.3.4 lib/ldap/digest.rb
dm-ldap-adapter-0.3.1 lib/ldap/digest.rb
dm-ldap-adapter-0.3.2 lib/ldap/digest.rb
dm-ldap-adapter-0.3.3 lib/ldap/digest.rb
dm-ldap-adapter-0.2.0 lib/ldap/digest.rb
dm-ldap-adapter-0.3.0 lib/ldap/digest.rb