nthash

package
v0.628.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package nthash computes the Windows NT hash (NTLM) of a password: the MD4 digest of the password encoded as little-endian UTF-16. It is the compute side of the credential toolkit — hash_identify recognises an NTLM hash and hash_crack attacks one, but neither can produce one. Computing an NT hash from a known or candidate password is the everyday primitive for confirming a cracked password, preparing a pass-the-hash value, or building test data. Pure offline compute from an operator-supplied string; no network or device interaction.

Wrap-vs-native judgement

Native. The NT hash is MD4(UTF-16LE(password)). MD4 (RFC 1320) is absent from the Go standard library (it is deprecated) and is otherwise only available from golang.org/x/crypto/md4 — itself a discouraged package. Rather than take that dependency, MD4 is implemented here directly (it is ~50 lines of the three RFC 1320 rounds), keeping the primitive owned in-tree and consistent with internal/otp, internal/hmacutil, internal/jwtsig and internal/wpa.

Verifiable / no confidently-wrong output

Strong verification class. MD4 is gated against the complete RFC 1320 Appendix A.5 test suite (MD4("") = 31d6cfe0…, MD4("abc") = a448017a…, the full seven-vector set), and NTHash against the universally published NTLM vector (NTHash("password") = 8846f7eaee8fb117ad06bdd830b7586c). The hash ships only if it reproduces every published vector, so no external oracle is needed.

Covered / deferred

Covered: the NT (NTLM) hash for any Unicode password (encoded UTF-16LE per the Windows convention), and the legacy LM hash (LMHash — DES of "KGS!@#$%" under each 7-byte half of the uppercased, 14-character password, the LANMAN algorithm). LM is gated against three cross-confirming references (the universal empty-LM, the published LM("password") pair, and the hashcat -m 3000 example), all reproduced via an independent DES oracle. Nothing is deferred — LM for non-ASCII passwords is OEM-codepage dependent and is rejected rather than guessed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LMHash added in v0.446.0

func LMHash(password string) ([]byte, error)

LMHash returns the 16-byte legacy LM (LANMAN) hash of password: the password is uppercased and truncated/padded to 14 bytes, split into two 7-byte halves, and each half keys a DES encryption of the constant "KGS!@#$%". LM is defined only for ASCII passwords (the uppercasing and byte mapping are OEM-codepage dependent otherwise), so a non-ASCII password is rejected rather than guessed.

func MD4

func MD4(data []byte) []byte

MD4 returns the 16-byte RFC 1320 MD4 digest of data.

func NTHash

func NTHash(password string) []byte

NTHash returns the 16-byte Windows NT (NTLM) hash of password: the MD4 digest of the password encoded as little-endian UTF-16, per the Windows convention.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL