CSharpTest.Net
Decrypt(String,ByteEncoding) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace > IEncryptDecrypt Interface > Decrypt Method : Decrypt(String,ByteEncoding) Method

text
encoding

Glossary Item Box

Decrypts a string from the specified encoding format

Syntax

Visual Basic (Declaration) 
Overloads Function Decrypt( _
   ByVal text As String, _
   ByVal encoding As ByteEncoding _
) As String
C# 
string Decrypt( 
   string text,
   ByteEncoding encoding
)

Parameters

text
encoding

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

Generated with Document! X 2011 by Innovasys