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

input

Glossary Item Box

Recreates a salt value from a string

Syntax

Visual Basic (Declaration) 
Public Shared Function FromString( _
   ByVal input As String _
) As Salt
C# 
public static Salt FromString( 
   string input
)

Parameters

input

Example

Library/Library.Test/TestSalt.cs

C#Copy Code
Salt s = new Salt();
byte[] bytes = new byte[s.Length];
s.CopyTo(bytes, 0);
Assert.AreEqual(s.ToArray(), bytes);
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode());

Salt strcpy = Salt.FromString(s.ToString());
Assert.AreEqual(s.ToArray(), strcpy.ToArray());
Assert.AreEqual(s.ToString(), strcpy.ToString());
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode());
VB.NETCopy Code
Dim s As New Salt()
Dim bytes As Byte() = New Byte(s.Length) {}
s.CopyTo(bytes, 0)
Assert.AreEqual(s.ToArray(), bytes)
Assert.AreEqual(s.GetHashCode(), Salt.FromBytes(bytes).GetHashCode())

Dim strcpy As Salt = Salt.FromString(s.ToString())
Assert.AreEqual(s.ToArray(), strcpy.ToArray())
Assert.AreEqual(s.ToString(), strcpy.ToString())
Assert.AreEqual(s.GetHashCode(), strcpy.GetHashCode())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys