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.CryptoAssembly: 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);
ac.Encrypt(new FileInfo(INPUT_FILE), new FileInfo(ENCRYPTED_FILE), pubKey);
Exceptions
Exception | Condition |
---|
System..::..ArgumentNullException | |
System..::..ArgumentException | Input file does not exist or has zero length |
See Also