Visual Basic (Declaration) | |
---|---|
Public ReadOnly Property BitSize As Salt.Size |
C# | |
---|---|
public Salt.Size BitSize {get;} |
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()) |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
Salt ClassSalt Members
Salt.Size
Used By
Stream PasswordKey.Decrypt(Stream)Byte[] PasswordKey.Decrypt(Byte[])