Parent

Methods

Net::LDAP::Password

Public Class Methods

generate(type, str) click to toggle source

Generate a password-hash suitable for inclusion in an LDAP attribute. Pass a hash type (currently supported: :md5 and :sha) and a plaintext password. This function will return a hashed representation.

# File lib/net/ldap/password.rb, line 17
def generate(type, str)
  digest, digest_name = case type
                        when :md5
                          [Digest::MD5.new, 'MD5']
                        when :sha
                          [Digest::SHA1.new, 'SHA']
                        else
                          raise Net::LDAP::LdapError, "Unsupported password-hash type (#{type})"
                        end
  digest << str.to_s
  return "{#{digest_name}}#{[digest.digest].pack('m').chomp }"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.