Returns a salted hash for the password
Syntax
Visual Basic (Declaration) | |
---|
Public Overloads Function CreateHash( _
ByVal salt As Salt _
) As PasswordHash |
Parameters
- salt
Example
Library/Library.Test/TestPassword.cs
C# | Copy Code |
---|
byte[] pwdBytes = Guid.NewGuid().ToByteArray();
using (Password pwd = new Password(false, pwdBytes))
{
using (PasswordHash hash = pwd.CreateHash())
Assert.IsTrue(hash.VerifyPassword(pwdBytes));
using (PasswordHash hash = new PasswordHash(pwd))
Assert.IsTrue(hash.VerifyPassword(pwdBytes));
}
using (Password pwd = new Password(false, pwdBytes))
{
using (PasswordHash hash = new PasswordHash(false, pwdBytes, new Salt()))
Assert.AreEqual(hash, pwd.CreateHash(hash.Salt));
} |
VB.NET | Copy Code |
---|
Dim pwdBytes As Byte() = Guid.NewGuid().ToByteArray()
Using pwd As New Password(False, pwdBytes)
Using hash As PasswordHash = pwd.CreateHash()
Assert.IsTrue(hash.VerifyPassword(pwdBytes))
End Using
Using hash As New PasswordHash(pwd)
Assert.IsTrue(hash.VerifyPassword(pwdBytes))
End Using
End Using
Using pwd As New Password(False, pwdBytes)
Using hash As New PasswordHash(False, pwdBytes, New Salt())
Assert.AreEqual(hash, pwd.CreateHash(hash.Salt))
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also