Python/Samba: Unterschied zwischen den Versionen

Aus Shea Wiki
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
 
K (1 Version importiert)
 
(kein Unterschied)

Aktuelle Version vom 20. Dezember 2021, 14:27 Uhr

Encoding sambaNTPassword With Python

Samba's sambaNTPassword attribute, which mimics the corresponding NT / Active Directory attribute, has a value that must be a hex encoded MD4 hash of the user's password with a UTF-16 encoding. Fortunately generating such a string is a Python one-liner.


import hashlib

password = 'fred123'
nt_password = hashlib.new('md4', password.encode('utf-16le')).digest().encode('hex').upper()


Note that Samba wants all the alpha characters in the string as upper-case. The result will always be 32 characters long.


KategorieWissen