Encrypt or decrypt a file stream.

Namespace: LLCryptoLib.Crypto
Assembly: LLCryptoLib (in LLCryptoLib.dll) Version: 2.0.1024.0 (2.0.1024)

Syntax

C#
public void EncryptDecrypt(
	FileStream inStream,
	FileStream outStream,
	bool isCrypting,
	CallbackPoint cbp
)
Visual Basic
Public Sub EncryptDecrypt ( _
	inStream As FileStream, _
	outStream As FileStream, _
	isCrypting As Boolean, _
	cbp As CallbackPoint _
)
Visual C++
public:
void EncryptDecrypt(
	FileStream^ inStream, 
	FileStream^ outStream, 
	bool isCrypting, 
	CallbackPoint^ cbp
)

Parameters

inStream
Type: System.IO..::..FileStream
File stream to read from. If isCrypting, clear file stream else a encrypted file stream.
outStream
Type: System.IO..::..FileStream
File stream to write to. if isCrypting, a encrypted file stream.
isCrypting
Type: System..::..Boolean
True if encryption, false if decryption.
cbp
Type: LLCryptoLib..::..CallbackPoint
The feedback will be filled with 1 point each CACHE_SIZE wrote.

Examples

CopyC#
// 1. Set algorithm
IStreamAlgorithm cryptoAlgo = StreamAlgorithmFactory.Create(SupportedStreamAlgorithms.BLOWFISH);

// 2. Encrypt 
StreamCrypter crypter = new StreamCrypter(cryptoAlgo);
crypter.GenerateKeys("littlelitesoftware");
crypter.EncryptDecrypt(rndFile.FullName, encryptedFile, true, null);
Console.WriteLine("File encrypted into " + encryptedFile);

// 3. Decrypt
StreamCrypter decrypter = new StreamCrypter(cryptoAlgo);
crypter.GenerateKeys("littlelitesoftware");
crypter.EncryptDecrypt(encryptedFile, decryptedFile, false, null);
Console.WriteLine("File decrypted into " + decryptedFile);

Exceptions

ExceptionCondition
LLCryptoLib..::..LLCryptoLibException
System..::..ArgumentNullException

See Also