Encrypts the specified input file and saves the encrypted bytes in the specified output file. To do so, a "session key" will be randomly generated and then encrypted using the publick key of the receiver. The public key may be obtained by a digital certificate, using a LLCertificate object. Then the message will be encrypted then using SupportedStreamAlgorithms algorithm supplied in the constructor with the encrypted key.

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

Syntax

C#
public void Encrypt(
	FileInfo inputFile,
	FileInfo outputFile,
	RSA rsaPublicKey
)
Visual Basic
Public Sub Encrypt ( _
	inputFile As FileInfo, _
	outputFile As FileInfo, _
	rsaPublicKey As RSA _
)
Visual C++
public:
void Encrypt(
	FileInfo^ inputFile, 
	FileInfo^ outputFile, 
	RSA^ rsaPublicKey
)

Parameters

inputFile
Type: System.IO..::..FileInfo
The input file.
outputFile
Type: System.IO..::..FileInfo
The output file.
rsaPublicKey
Type: System.Security.Cryptography..::..RSA
The receiver public key.

Examples

CopyC#
AsymmetricCrypter ac = new AsymmetricCrypter(SupportedStreamAlgorithms.BLOWFISH256);
RSA pubKey = AsymmetricCrypter.LoadKeyFromXmlFile(PUBLIC_KEY);
// or RSA pubKey = AsymmetricCrypter.LoadPublicKeyFromCER(PUBLIC_KEY_CER);
ac.Encrypt(new FileInfo(INPUT_FILE), new FileInfo(ENCRYPTED_FILE), pubKey);

Exceptions

ExceptionCondition
System..::..ArgumentNullException
System..::..ArgumentExceptionInput file does not exist or has zero length

See Also