public void NTHash_GenerateRandom() { byte[] randomHash1 = NTHash.GetRandom(); byte[] randomHash2 = NTHash.GetRandom(); // Check hash size Assert.AreEqual(NTHash.HashSize, randomHash1.Length); // Check that the hashes are not the same Assert.AreNotEqual(randomHash1.ToHex(), randomHash2.ToHex()); }
public SupplementalCredentials(SecureString password, string samAccountName, string userPrincipalName, string netBiosDomainName, string dnsDomainName) { // Input validation Validator.AssertNotNull(password, "password"); Validator.AssertNotNull(samAccountName, "samAccountName"); // Note that UPN can be NULL, as it is an optional user attribute. Validator.AssertNotNull(netBiosDomainName, "netBiosDomainName"); Validator.AssertNotNull(dnsDomainName, "dnsDomainName"); // Generate Kerberos keys this.Kerberos = new KerberosCredential(password, samAccountName, dnsDomainName); this.KerberosNew = new KerberosCredentialNew(password, samAccountName, dnsDomainName); // Generate WDigest hashes this.WDigest = WDigestHash.ComputeHash(password, userPrincipalName, samAccountName, netBiosDomainName, dnsDomainName); // Generate a random NTLM strong hash that is definitely not based on a password. this.NTLMStrongHash = NTHash.GetRandom(); // Note that we do not want to store the password in cleartext. }