Class: Net::LDAP::Password

### Home Classes Methods

### In Files

- lib/net/ldap/password.rb

### Parent

Object

### Methods

- ::generate

### Files

- History.rdoc
- Manifest.txt

### Class/Module Index

Quicksearch

- Net
- Net::BER
- Net::BER::BERParser
- Net::BER::BerError
- Net::BER::BerIdentifiedArray
- Net::BER::BerIdentifiedNull
- Net::BER::BerIdentifiedOid
- Net::BER::BerIdentifiedString
- Net::BER::Extensions
- Net::BER::Extensions::Array
- Net::BER::Extensions::Bignum
- Net::BER::Extensions::FalseClass
- Net::BER::Extensions::Fixnum
- Net::BER::Extensions::String
- Net::BER::Extensions::TrueClass
- Net::LDAP
- Net::LDAP::Connection
- Net::LDAP::Connection::GetbyteForSSLSocket
- Net::LDAP::DN
- Net::LDAP::Dataset
- Net::LDAP::Entry
- Net::LDAP::Filter
- Net::LDAP::LdapControls
- Net::LDAP::LdapError
- Net::LDAP::PDU
- Net::LDAP::PDU::Error
- Net::LDAP::Password
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLSocket

No matching classes.

# 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.