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

salt

Glossary Item Box

Returns a salted hash for the password

Syntax

Visual Basic (Declaration) 
Public Overloads Function CreateHash( _
   ByVal salt As Salt _
) As PasswordHash
C# 
public PasswordHash CreateHash( 
   Salt salt
)

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