CSharpTest.Net
Salt.Size Enumeration
Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : Salt.Size Enumeration

Glossary Item Box

Size of a salt-key in bits

Syntax

Visual Basic (Declaration) 
Public Enum Salt.Size 
   Inherits System.Enum
C# 
public enum Salt.Size : System.Enum 

Members

MemberDescription
b10241024-bit, 128-byte salt value
b128128-bit, 16-byte salt value
b256256-bit, 32-byte salt value
b512512-bit, 64-byte salt value
b6464-bit, 8-byte salt value

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

System.Object
   System.ValueType
      System.Enum
         CSharpTest.Net.Crypto.Salt.Size

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys