Module: Samba::Encrypt
- Defined in:
- lib/samba/encrypt.rb
Defined Under Namespace
Modules: Private
Class Method Summary collapse
Class Method Details
.lm_hash(password, encoding = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/samba/encrypt.rb', line 6 def lm_hash(password, encoding=nil) dos_password = Private.convert_encoding("ISO-8859-1", encoding || "UTF-8", password.upcase) if dos_password.size > 14 warn("password is truncated to 14 characters") dos_password = dos_password[0, 14] end Private.encrypt_14characters(dos_password).unpack("C*").collect do |char| "%02X" % char end.join end |
.ntlm_hash(password, encoding = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/samba/encrypt.rb', line 19 def ntlm_hash(password, encoding=nil) ucs2_password = Private.convert_encoding("UCS-2", encoding || "UTF-8", password) if ucs2_password.size > 256 raise ArgumentError.new("must be <= 256 characters in UCS-2") end hex = OpenSSL::Digest::MD4.new(ucs2_password).hexdigest.upcase hex end |