Size of a salt-key in bits
Syntax
Visual Basic (Declaration) | |
---|
Public Enum Salt.Size
Inherits System.Enum |
Members
Example
Library/Library.Test/TestSalt.cs
C# | Copy Code |
---|
byte[] testValid = Encoding.ASCII.GetBytes("12345678");
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize);
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray());
testValid = null;
//now test with an odd number of bytes, should always hash to Sha256
byte[] notValid = Encoding.ASCII.GetBytes("0123456789");
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize);
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray());
Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize);
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray()); |
VB.NET | Copy Code |
---|
Dim testValid As Byte() = Encoding.ASCII.GetBytes("12345678")
Assert.AreEqual(Salt.Size.b64, Salt.FromBytes(testValid).BitSize)
Assert.AreEqual(testValid, Salt.FromBytes(testValid).ToArray())
testValid = Nothing
'now test with an odd number of bytes, should always hash to Sha256
Dim notValid As Byte() = Encoding.ASCII.GetBytes("0123456789")
Assert.AreNotEqual(Salt.Size.b64, Salt.FromBytes(notValid).BitSize)
Assert.AreNotEqual(testValid, Salt.FromBytes(notValid).ToArray())
Assert.AreEqual(Salt.Size.b256, Salt.FromBytes(notValid).BitSize)
Assert.AreEqual(Hash.SHA256(notValid).ToArray(), Salt.FromBytes(notValid).ToArray()) |
Inheritance Hierarchy
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also