алгоритм AES 256 для шифрования данных. но AES: по умолчанию — CBC.
Я хотел установить режим «CTR» для шифрования, но не нашел способа.
Ниже приведен мой код для шифрования данных.
Код: Выделить всё
private static void EncryptFile(string inputFile, string outputFile, string publicKeyPath) {
using (Stream outputStream = File.Create(outputFile))
using (Stream inputStream = File.OpenRead(inputFile))
using (Stream publicKeyStream = File.OpenRead(publicKeyPath))
{
PgpPublicKey publicKey = ReadPublicKey(publicKeyStream);
PgpEncryptedDataGenerator encryptedDataGen = new PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag.Aes256, true, new SecureRandom());
encryptedDataGen.AddMethod(publicKey);
using (Stream compressedDataStream = encryptedDataGen.Open(outputStream, new byte[4096]))
using (Stream compressedData = new PgpCompressedDataGenerator(CompressionAlgorithmTag.Zip).Open(compressedDataStream))
{
inputStream.CopyTo(compressedData);
}
}
Спасибо. Предварительно
Подробнее здесь: https://stackoverflow.com/questions/790 ... ion-method