How to use OpenPGP to decrypt from one blob to another(如何使用OpenPGP将一个BLOB解密为另一个BLOB)
                            本文介绍了如何使用OpenPGP将一个BLOB解密为另一个BLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
                        
                        问题描述
我每天都会将几个PGP加密文件导入到我的BLOB存储中。我需要能够将它们解密到同一个斑点容器中的另一个位置。我已经知道我必须在ADF中创建自定义批处理活动才能做到这一点,我只是想不出如何将BLOB发送到OpenPGP
这段来自bitscry.com的示例代码建议使用STREAMS作为示例:
using (FileStream inputFileStream = new FileStream(@"C:TEMPkeyscontent__encrypted2.pgp", FileMode.Open))
using (Stream outputFileStream = File.Create(@"C:TEMPkeyscontent__decrypted2.txt"))
using (Stream privateKeyStream = new FileStream(@"C:TEMPkeysprivate.asc", FileMode.Open))
    pgp.DecryptStream(inputFileStream, outputFileStream, privateKeyStream, "password");
我已尝试将Blob作为流打开,但不起作用。
以下是尝试将Blob用作流的代码:
        Stream sourceStream = keyBlockBlob.OpenRead();
        Stream keyStream = sourceCloudBlockBlob.OpenRead();
        Stream targetStream = targetCloudBlockBlob.OpenWrite();
        pgp.DecryptStream(sourceStream, targetStream, keyStream, "password");
推荐答案
我发现自己做错了什么。在传递到DecyptStream之前,我没有将流位置重置为零。此代码起作用:
        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);
                        这篇关于如何使用OpenPGP将一个BLOB解密为另一个BLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
				 沃梦达教程
				
			本文标题为:如何使用OpenPGP将一个BLOB解密为另一个BLOB
				
        
 
            
        
             猜你喜欢
        
	     - MoreLinq maxBy vs LINQ max + where 2022-01-01
 - WebMatrix WebSecurity PasswordSalt 2022-01-01
 - 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
 - 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
 - Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
 - 如何用自己压缩一个 IEnumerable 2022-01-01
 - 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
 - C# 中多线程网络服务器的模式 2022-01-01
 - C#MongoDB使用Builders查找派生对象 2022-09-04
 - 输入按键事件处理程序 2022-01-01
 
						
						
						
						
						
				
				
				
				