Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用OpenPGP从一个blob解密到另一个blob_C#_Azure Storage_Openpgp - Fatal编程技术网

C# 如何使用OpenPGP从一个blob解密到另一个blob

C# 如何使用OpenPGP从一个blob解密到另一个blob,c#,azure-storage,openpgp,C#,Azure Storage,Openpgp,我每天将几个PGP加密文件导入blob存储。我需要能够将它们解密到同一blob容器中的另一个位置 我已经知道我必须在ADF中创建一个定制的批处理活动来完成这项工作,我只是不知道如何将blob发送到OpenPgp 来自bitscry.com的示例代码建议使用流作为示例: using (FileStream inputFileStream = new FileStream(@"C:\TEMP\keys\content__encrypted2.pgp", FileMode.Open)) using (

我每天将几个PGP加密文件导入blob存储。我需要能够将它们解密到同一blob容器中的另一个位置

我已经知道我必须在ADF中创建一个定制的批处理活动来完成这项工作,我只是不知道如何将blob发送到OpenPgp

来自bitscry.com的示例代码建议使用流作为示例:

using (FileStream inputFileStream = new FileStream(@"C:\TEMP\keys\content__encrypted2.pgp", FileMode.Open))
using (Stream outputFileStream = File.Create(@"C:\TEMP\keys\content__decrypted2.txt"))
using (Stream privateKeyStream = new FileStream(@"C:\TEMP\keys\private.asc", FileMode.Open))
    pgp.DecryptStream(inputFileStream, outputFileStream, privateKeyStream, "password");
我试着把这些斑点当作溪流打开,但它不起作用

这是尝试将blob用作流的代码:

        Stream sourceStream = keyBlockBlob.OpenRead();
        Stream keyStream = sourceCloudBlockBlob.OpenRead();
        Stream targetStream = targetCloudBlockBlob.OpenWrite();

        pgp.DecryptStream(sourceStream, targetStream, keyStream, "password");

我知道我做错了什么。在传递到解密流之前,我没有将流位置重置为零。此代码适用于:

        var sourceStream = new MemoryStream();
        var keyStream = new MemoryStream();
        var targetStream = new MemoryStream();

        sourceCloudBlockBlob.DownloadToStream(sourceStream);
        sourceStream.Position = 0;

        keyBlockBlob.DownloadToStream(keyStream);
        keyStream.Position = 0;


        pgp.DecryptStream(sourceStream, targetStream, keyStream, "password");
        targetStream.Position = 0;
        targetCloudBlockBlob.UploadFromStream(targetStream);