Sha256: 798eff6b9cf5db2730bc1e412338198476ffa0f7c59ad971d1ed1cada9b272b5

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 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

5 entries across 5 versions & 1 rubygems

Version Path
dm-ldap-adapter-0.4.1 lib/ldap/digest.rb
dm-ldap-adapter-0.4.0 lib/ldap/digest.rb
dm-ldap-adapter-0.4.0.alpha4 lib/ldap/digest.rb
dm-ldap-adapter-0.4.0.alpha3 lib/ldap/digest.rb
dm-ldap-adapter-0.4.0.alpha2 lib/ldap/digest.rb