CSharpTest.Net
PasswordHash Constructor(Password)
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class > PasswordHash Constructor : PasswordHash Constructor(Password)

bytes

Glossary Item Box

Creates a salted hash from the given password

Syntax

Visual Basic (Declaration) 
Public Function New( _
   ByVal bytes As Password _
)
C# 
public PasswordHash( 
   Password bytes
)

Parameters

bytes

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.NETCopy 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

Generated with Document! X 2011 by Innovasys