Class: Net::LDAP::Password
- Inherits:
-
Object
- Object
- Net::LDAP::Password
- Defined in:
- lib/net/ldap/psw.rb
Class Method Summary collapse
-
.generate(type, str) ⇒ Object
Generate a password-hash suitable for inclusion in an LDAP attribute.
Class Method Details
.generate(type, str) ⇒ Object
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. STUB: This is here to fulfill the requirements of an RFC, which one? TODO, gotta do salted-sha and (maybe) salted-md5. Should we provide sha1 as a synonym for sha1? I vote no because then should you also provide ssha1 for symmetry?
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/net/ldap/psw.rb', line 43 def generate( type, str ) case type when :md5 require 'digest/md5' "{MD5}#{ [Digest::MD5.digest( str.to_s )].pack("m").chomp }" when :sha require 'digest/sha1' "{SHA}#{ [Digest::SHA1.digest( str.to_s )].pack("m").chomp }" # when ssha else raise Net::LDAP::LdapError.new( "unsupported password-hash type (#{type})" ) end end |