Encrypts a string and encodes the result in specified encoding format
Syntax
Example
Library/Library.Test/TestEncryption.cs
C# | Copy Code |
---|
string value = TEST_PASSWORD;
Encryption.Passthrough.Dispose();//ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value));
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex));
byte[] bytes = Password.Encoding.GetBytes(value);
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes));
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(new MemoryStream(bytes))));
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(new MemoryStream(bytes)))); |
VB.NET | Copy Code |
---|
Dim value As String = TEST_PASSWORD
Encryption.Passthrough.Dispose()
'ignores
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Encrypt(value, ByteEncoding.Hex))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value))
Assert.AreEqual(value, Encryption.Passthrough.Decrypt(value, ByteEncoding.Hex))
Dim bytes As Byte() = Password.Encoding.GetBytes(value)
Assert.AreEqual(bytes, Encryption.Passthrough.Encrypt(bytes))
Assert.AreEqual(bytes, Encryption.Passthrough.Decrypt(bytes))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Encrypt(New MemoryStream(bytes))))
Assert.AreEqual(bytes, IOStream.ReadAllBytes(Encryption.Passthrough.Decrypt(New MemoryStream(bytes)))) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also