Sha256: 2928544df05b99ba3dd87442000a6c665f9ea9f6647c9959315354b939c57271

Contents?: true

Size: 781 Bytes

Versions: 10

Compression:

Stored size: 781 Bytes

Contents

begin
  require 'sha1'
rescue LoadError
  # ruby1.9.x
  require 'digest/sha1'
  SHA1 = Digest::SHA1
end

require 'base64'
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)
      (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

10 entries across 10 versions & 1 rubygems

Version Path
dm-ldap-adapter-0.4.7 lib/ldap/digest.rb
dm-ldap-adapter-0.4.8 lib/ldap/digest.rb
dm-ldap-adapter-0.4.6 lib/ldap/digest.rb
dm-ldap-adapter-0.4.6-java lib/ldap/digest.rb
dm-ldap-adapter-0.4.5-java lib/ldap/digest.rb
dm-ldap-adapter-0.4.5 lib/ldap/digest.rb
dm-ldap-adapter-0.4.4-java lib/ldap/digest.rb
dm-ldap-adapter-0.4.4 lib/ldap/digest.rb
dm-ldap-adapter-0.4.3-java lib/ldap/digest.rb
dm-ldap-adapter-0.4.3 lib/ldap/digest.rb