open_vPGPv
加密
// create an instance of the library
PGPLib pgp = new PGPLib(); // Import the main company public key
pgp.AddMasterKey(@"xx.asc"); // after the encryption the output file will be encrypted with two keys
pgp.EncryptFile(@"input.txt", @"xx.asc", @"input.txt.pgp");
MessageBox.Show("杀杀杀");
解密
// initialize the library
PGPLib pgp = new PGPLib(); string inputFileLocation = @"input.txt.pgp";
string privateKeyLocation = @"pv.asc";
string privateKeyPassword = "6446-";
string decryptedOutput = @"input2.txt"; try
{
string originalFileName =
pgp.DecryptFile(inputFileLocation,
privateKeyLocation,
privateKeyPassword,
decryptedOutput); Console.WriteLine("File decrypted to :" + decryptedOutput);
Console.WriteLine("The original file name of the decrypted file was :" + originalFileName);
}
catch (PGPException e)
{
if (e is NonPGPDataException)
{
Console.WriteLine("The input file is not an OpenPGP archive or is corrupted");
}
else if (e is WrongPrivateKeyException)
{
// The message cannot be decrypted with this private key
// or the supplied private key is not an OpenPGP private key or is corrupted
Console.WriteLine(e.Message);
}
else if (e is WrongPasswordException)
{
Console.WriteLine("The password for the private key is incorrect");
}
else if (e is FileIsPBEEncryptedException)
{
Console.WriteLine("The input file is password encrypted.");
Console.WriteLine("You have to use DecryptAndVeifyFilePBE or DecryptAndVerifyStreamPBE");
}
else if (e is IntegrityCheckException)
{
Console.WriteLine("The encrypted data is corrupted");
}
else
{
Console.WriteLine(e.Message);
}
}
EnryptFileToExe
// initialize the SFX generator class
SfxCreator sfx = new SfxCreator(); // encrypt the data file and create an executable
sfx.EnryptFileToExe(@"input2.txt", "644611", @"input2.exe");
key.store
// initialize the KeyStore
// If the keystore file does not exists, it is created.
KeyStore ks = new KeyStore(@"key.store", "changeit"); String userId = "support@didisoft.com";
if (!ks.ContainsKey(userId))
{
// Generate RSA based OpenPGP key with predefined parameters;
// for more customized generation see GenerateKeypairRSA.cs
// (Note: the predefined key parameters here are the same as in PGP Desktop version 10)
ks.GenerateKeyPair(2048, "support@didisoft.com", "changeit");
}
ks.ExportPublicKey("mypb.txt", userId, true);
ks.ExportPrivateKey("mypv.txt", userId, true);
MessageBox.Show("ok");
加
// create an instance of the library
PGPLib pgp = new PGPLib(); // Import the main company public key
// pgp.AddMasterKey(@"xx.asc"); // after the encryption the output file will be encrypted with two keys
pgp.EncryptFile(@"input.txt", @"mypb.txt", @"input_ks.txt.pgp");
MessageBox.Show("杀杀杀");
解
// create an instance of the library
PGPLib pgp = new PGPLib(); //pgp.DecryptFile(@"input_ks.txt.pgp", @"mypv.txt", "changeit", @"input_ks.txt"); KeyStore ks = new KeyStore(@"key.store", "changeit");
pgp.DecryptFile(@"input_ks.txt.pgp",ks, "changeit", @"input_ks.txt");
MessageBox.Show("杀杀杀");
OpenPGP Library v.1.7
http://www.winsite.com/Development/Components-Libraries/OpenPGP-Library-for-NET/
http://bbs.csdn.net/topics/390267637
Bin】下的【BouncyCastle.CryptoExt.dll】和【DidiSoft.Pgp.dll】引用到项目中,就可以很方便的在C#中使用PGP加解密了。
https://www.didisoft.com/net-openpgp/examples/decrypt-and-verify/
https://www.didisoft.com/net-openpgp/
https://www.componentsource.com/product/openpgp-library-for-dotnet
http://www.pgp.cn/index.htm
open_vPGPv的更多相关文章
随机推荐
- 解决Shell脚本$'\r': command not found问题
造成这个问题的原因是Windows下的空行,我们只需要把文件转成unix就好 Centos下,执行yum install dos2unix,然后dos2unix [file],再执行shell命令就好 ...
- ICEM-带柱底座
原视频下载地址:https://pan.baidu.com/s/1c2KgCBA 密码: ixk8
- ICEM-哑铃
原视频下载地址:https://pan.baidu.com/s/1kVBKJbT ;密码: jqeh
- hadoop作业
作业要求:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/3223 一.准备一个ubantu 系统 二.创建hadoop用户 创建 设密 ...
- 第10组 Beta冲刺(3/5)
链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 小组内容 恩泽(组长) 过去两天完成了哪些任务 描述 新增修改用户信息.任务完成反馈等功能API 服务器后端部署,API接口的bet ...
- idea在docker环境,调试spring boot程序
允许docker被远程访问 见:https://www.cnblogs.com/wintersoft/p/10921396.html 教程见:https://spring.io/guides/gs/s ...
- ElementUi tree 指定节点是否显示复选框
场景:树的内容是省份下面的城市有酒店 需求:只能多选酒店(为了删除它们),至于为啥不能选省份或者城市更加灵活的去删除相应酒店,这你得去问后台0.0,他只弄了根据酒店id去删除.嗯,连创建酒店的时候级联 ...
- [E2E_L9]Linux命令行上传文件到百度网盘
百度有2TB 存储空间,在有第三方服务器的情况下,很多东西不需要下载到本地,可以直接使用服务转存,这非常好. 系统环境: Linux 系统 + Python 2.7 安装软件工具:[可能会要重复装] ...
- django 表操作
添加表纪录 # Create your models here. class Book(models.Model): id = models.AutoField(primary_key=True) t ...
- jwplayer :若请求不到流,则页面一直转圈请求效果
思路: 利用jwplayer onPlay(播放) .onError(出错)事件. 页面:背景图为黑色,嵌入一张背景为黑色的 git 动态图,加载页面时隐藏. 流程:若进入到onPlay 方法,则说明 ...