Parameters
- data
Library/Library.Test/TestPasswordHash.cs
C# | Copy Code |
---|---|
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD)) { //no salt provided using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD)) Assert.AreNotEqual(pwd1, pwd2); using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD))) Assert.AreNotEqual(pwd1, pwd2); //identical salt using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt)) Assert.AreEqual(pwd1, pwd2); using (PasswordHash pwd2 = new PasswordHash(false, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt)) Assert.AreEqual(pwd1, pwd2); using (PasswordHash pwd2 = new PasswordHash(new MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt)) Assert.AreEqual(pwd1, pwd2); using (PasswordHash pwd2 = new PasswordHash(new Password(TEST_PASSWORD), pwd1.Salt)) Assert.AreEqual(pwd1, pwd2); using (SecureString sstr = SecureStringUtils.Create(TEST_PASSWORD)) { using (PasswordHash pwd2 = new PasswordHash(sstr, pwd1.Salt)) Assert.AreEqual(pwd1, pwd2); using (PasswordHash pwd2 = new PasswordHash(sstr)) Assert.AreNotEqual(pwd1, pwd2); } } |
VB.NET | Copy Code |
---|---|
Using pwd1 As New PasswordHash(TEST_PASSWORD) 'no salt provided Using pwd2 As New PasswordHash(TEST_PASSWORD) Assert.AreNotEqual(pwd1, pwd2) End Using Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD)) Assert.AreNotEqual(pwd1, pwd2) End Using 'identical salt Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt) Assert.AreEqual(pwd1, pwd2) End Using Using pwd2 As New PasswordHash(False, Password.Encoding.GetBytes(TEST_PASSWORD), pwd1.Salt) Assert.AreEqual(pwd1, pwd2) End Using Using pwd2 As New PasswordHash(New MemoryStream(Password.Encoding.GetBytes(TEST_PASSWORD)), pwd1.Salt) Assert.AreEqual(pwd1, pwd2) End Using Using pwd2 As New PasswordHash(New Password(TEST_PASSWORD), pwd1.Salt) Assert.AreEqual(pwd1, pwd2) End Using Using sstr As SecureString = SecureStringUtils.Create(TEST_PASSWORD) Using pwd2 As New PasswordHash(sstr, pwd1.Salt) Assert.AreEqual(pwd1, pwd2) End Using Using pwd2 As New PasswordHash(sstr) Assert.AreNotEqual(pwd1, pwd2) End Using End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
PasswordHash ClassPasswordHash Members
Overload List