【发布时间】:2021-08-13 18:40:32
【问题描述】:
我开发了这个使用 AES-GCM 算法真正加密文件的 C# 系统。但是,我不希望加密文件与原始文件夹位于同一文件夹中。我怎样才能改变它?以下是我的代码片段以及我需要帮助的地方。
foreach (string inputFilePath in inputFilePaths)
{
// Proceed if file exists
if (File.Exists(inputFilePath))
{
try
{
// Encrypt
byte[] key = PasswordAsKey();
string[] encryptedFileContents = AesGcmFileEncryption.Encrypt(inputFilePath, key);
// Here is where I need clarification
string outputFilePath = inputFilePath;
outputFilePath += ".AEncrypt";
if (File.Exists(outputFilePath))
{
skippedBecauseFileExists = true;
}
else
{
File.WriteAllLines(outputFilePath, encryptedFileContents);
counter++;
// Status
label10.Text = "Copied and encrypted \"" + Path.GetFileName(inputFilePath) + "\"";
}
}
catch (Exception ex)
【问题讨论】:
标签: c# encryption cryptography aes-gcm