CSharpTest.Net
FromBytes Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > PasswordHash Class : FromBytes Method

hash

Glossary Item Box

recreates a hash from the bytes returned by ToArray()

Syntax

Visual Basic (Declaration) 
Public Shared Function FromBytes( _
   ByVal hash() As Byte _
) As PasswordHash
C# 
public static PasswordHash FromBytes( 
   byte[] hash
)

Parameters

hash

Example

Library/Library.Test/TestPasswordHash.cs

C#Copy Code
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = PasswordHash.FromBytes(pwd1.ToArray()))
{
    Assert.AreEqual(pwd1, pwd2);
    Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Length, pwd2.Length);
    Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
    Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());
}
VB.NETCopy Code
Using pwd1 As New PasswordHash(TEST_PASSWORD)
    Using pwd2 As PasswordHash = PasswordHash.FromBytes(pwd1.ToArray())
        Assert.AreEqual(pwd1, pwd2)
        Assert.AreEqual((256 / 8) + pwd1.Salt.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Length, pwd2.Length)
        Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
        Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())
    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