Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

基于GPG的加密数据的传送[0]

Posted on 2023年11月14日 by

项目地址:https://www.gnupg.org

win的下载地址:https://gpg4win.org/download.html

类似项目:https://www.openpgp.org/

  • 背景

1)常用的压缩和解压缩软件的用的加密都是对称加密,而对方使用解码的方式是需要知道密码才可以解开,对于第三方而言暴力破解有价值的文档是值得的,尤其是采用超算进行破解,并且密码在传输的过程中也容易泄漏,导致加密本身没有意义。尤其是对于加密存储在公有云上的文档,采用公有云的在线解压缩,本身就会泄漏密码

2)GPG

GNU Privacy Guard(GnuPG 或 GPG)是一个密码学软件,用于加密、签名通信内容及管理非对称密码学的密钥。GnuPG 是自由软件,遵循 IETF 订定的 OpenPGP 技术标准设计,并与 PGP 保持兼容。

3)当前的互联网的隐私保护非常的弱,无论是传输途径还是加密方式,为了解决再不安全的传输路径上保持信息的安全,采用加密是一种不错是方式,尤其时非实时数据流。对于实时数据流采用混淆更加合适。

4)有些时候,对于文件的内容是无需加密的,但是需要防止被别人篡改性能,为了保障信息的可靠,还可以直接进行签名,将签名在文件下载后进行校验,常用的校验有md5值,也可以是sha256sum,这种方式非常适合远程公开下载的情况下,防止第三方做手脚。

  • 基础

详见非对称加密及其应用

  • 安装

1)下载并校验

校验通过,文件下载完整

2)安装步骤

此机器成为A机器,安装信息如下:

中文化

创建本地证书

注意:以上设置没有过期日期

  • 测试

需要在另外一台机器上再部署一次GPG,此机器成为B机器,主要信息如下:

文件的加解密

A机器加密文件,B机器解密文件

1)B机器将其公钥发送给A机器

2)A机器导入B的公钥

3)A机器上加密文件

原文件

加密

加密后的文件

4)B机器上进行解密

获取的原文,但是存在校验错误

5)解决B机器上的校验错误

需要将A的公钥导入到B的软件中,并认证A的公钥,再次解密和校验效果如下:

文件校验

在A机器上产生sha256sum校验文件,并在B机器上也产生sha256sum文件,并进行对比即可,两者应该相同,否则文件被修改。

A机器上的校验和

B机器的校验和

两者相同。

 

  • 小结

1)导出的公钥不会变化

2)对别人加密,得到的加密文件自己是打不开的。

3)传递的公钥即便是被拦截了,也无法破解加密文件

4)加密和校验是两个需求不同的任务

 

补充说明:

1)公钥存储服务器

https://www.keyserver.net/

https://keybase.io/

keyserver.ubuntu.com

keys.openpgp.org

2)centos使用已有的GPG密钥对,并进行文件加密

#导入私钥,给自己加密无需导入公钥
gpg --import Brain_SECRET.asc
#列出密钥
gpg --list-key
#删除私钥
gpg --delete-secret-keys info@fanlog.org
#删除公钥
gpg --delete-keys info@fanlog.org
#给Brain <info@fanlog.org>加密test.zip文件,在当前位置
gpg --encrypt --recipient "Brain <info@fanlog.org>" test.zip

下载到本地用winGPG界面成功,测试通过

3)key的信任问题

避免Use this key anyway问题

gpg --edit-key info@fanlog.org
trust
5

 

参考资料:

  1. https://www.ruanyifeng.com/blog/2013/07/gpg.html
  2. https://wwj718.github.io/post/%E5%B7%A5%E5%85%B7/e2ee/
  3. https://www.gnupg.org/howtos/zh/
  4. https://www.leixue.com/ask/what-is-gnupg
  5. https://blog.csdn.net/willingtolove/article/details/122362705
  6. https://cloud.tencent.com/developer/article/1666183
  7. https://www.howtoing.com/gpg-file-encryption-command-line-in-linux
  8. https://www.ruanyifeng.com/blog/2013/07/gpg.html
  9. https://blog.csdn.net/vic_qxz/article/details/127242254
  10. https://bbs.huaweicloud.com/blogs/290331
  11. https://blog.csdn.net/nyist_zxp/article/details/107597626
  12. https://www.pianshen.com/article/64131882208/
  13. https://zhuanlan.zhihu.com/p/445631720

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT