1. 生成秘钥对(此处采用默认的RSA, 2048位)

$ gpg --gen-key
gpg (GnuPG) 2.0.; Copyright (C) Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. gpg: directory `/home/webadmin/.gnupg' created
gpg: new configuration file `/home/webadmin/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/webadmin/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/webadmin/.gnupg/secring.gpg' created
gpg: keyring `/home/webadmin/.gnupg/pubring.gpg' created
Please select what kind of key you want:
() RSA and RSA (default)
() DSA and Elgamal
() DSA (sign only)
() RSA (sign only)
Your selection?
RSA keys may be between and bits long.
What keysize do you want? ()
Requested keysize is bits
Please specify how long the key should be valid.
= key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? () 10y

最后生成完成后,会有下列的信息显示:

public and secret key created and signed.

2. 查看有哪些公钥

$ gpg --list-keys

3. 导出公钥(用于加密)(ASCII格式适合程序中使用)

$ gpg -a -o pubkey.txt --export test01

此处test01是 --list-keys罗列出来的uid。

4. 导出私钥(用于解密)

$ gpg -a -o prikey.txt --export-secret-keys test01

5. 测试加密和解密

$ gpg  -r test01 -e test.txt

$ gpg -r test01 -o test.txt -d test.txt.gpg

GnuPG 的PGP使用的更多相关文章

  1. 《Maven实战》阅读笔记

    java -versionmvn -vmvn help:system m2eclipse maven->install MAVEN_OPTS: -Xms128m -Xmx512mmvn clea ...

  2. DH、RSA与ElGamal非对称加密算法实现及应用

    1.对称加密与非对称加密概述 关于对称加密与非对称加密的概念这里不再多说,感兴趣可以看下我之前的几篇文章,下面说一说两者的主要区别. 对称加密算法数据安全,密钥管理复杂,密钥传递过程复杂,存在密钥泄露 ...

  3. 使用GnuPG(PGP)加密信息及数字签名教程_转

    所谓加解密就是一方以密钥加密,另一外收到文件后以相对应的密钥解密,从而获取原始文件.数字签名的过程:信息是通过普通未加密方式发送信息给对方的,只是在每条信息后面都会附加一坨字符(名曰:签名)(或信息与 ...

  4. openpgp和gnupg

    http://www.openpgp.org/about_openpgp/history.shtml https://www.gnupg.org/ History OpenPGP is a non-p ...

  5. Linux下校验下载文件的完整性(MD5,SHA1,PGP)

    查看: Linux下校验下载文件的完整性(MD5,SHA1,PGP) http://blog.useasp.net/archive/2014/03/29/use-md5-sha1-or-pgp-to- ...

  6. 在Linux上使用PGP签名验证文件完整性

    文件在下载及存储过程中可能由于传输错误.硬件故障.文件系统错误等网络.硬件和软件方面的原因导致文件损坏,也可能在传输过程中受到攻击(如"中间人攻击")导致下载的文件被篡改或者下载到 ...

  7. GPG(GnuPG)入门

    GPG(GnuPG)入门 下载: https://gnupg.org/download/index.html 或者 http://www.hellopp.cn/page/5b9a1405c3f1f7d ...

  8. PGP NO_PUBKEY

    horizon@horizon-pc ~ $ sudo apt-get update Ign http://packages.linuxmint.com rebecca/upstream Transl ...

  9. 非对称加密与GPG/PGP

    最近浏览博客的时候,经常会看到博主展示出自己的公钥,于是对 GPG/PGP 产生兴趣.下面简单记录相关文章的链接,方便以后了解. 简介: 1991年,程序员Phil Zimmermann为了避开政府的 ...

随机推荐

  1. spring security自定义拒绝访问页面

    如果试图访问一个没有访问权限的页面,那么页面会出现403 访问错误. 如果我们希望自定义访问拒绝页面,只需要随便创建一个jsp页面,让后将这个页面的位置放到配置文件中. 下面创建一个accessDen ...

  2. 用vs2013编译lua源码方法(一)

    用vs2013编译lua源码方法 来源:网络    编辑:admin 1.下载lua源码:lua-5.2.3.tar.gz,解压 2.用vs2013建立一个win32工程: 1)下载后解压到一个目录下 ...

  3. php for循环嵌套

    <?php     //2.打印一个50*50的 'o' 的正方形方整, 使用for的嵌套     // oooooo     // oooooo     // oooooo //for循环嵌套 ...

  4. 关于Random类产生随机数的一些问题

    package test2; import java.util.Random; /** * @author cy * * @date 2015年7月28日 上午8:47:52 * * @Descrip ...

  5. HTTP Status 500 - org.apache.jasper.JasperException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException

    HTTP Status 500 - org.apache.jasper.JasperException: com.sun.org.apache.xerces.internal.impl.io.Malf ...

  6. Android课程---Activity中保存和恢复用户状态

    onSaveInstanceState 保存 在暂停之后和保存之前调用 onRestoreInstanceState 恢复 再启动之后和显示之前调用 package com.example.chens ...

  7. Network | UDP checksum

    1. 校验和 ICMP,IP,UDP,TCP报头部分都有checksum(检验和)字段.IP 首部里的校验和只校验首部:ICMP.IGMP.TCP和UDP首部中的校验和校验首部和数据. UDP和TCP ...

  8. free-library-converts-2d-image-to-3d

    http://www.i-programmer.info/news/105-artificial-intelligence/4917-free-library-converts-2d-image-to ...

  9. mongoose index

    1. 当应用程序启动时,Mongoose会自动为模式中的每个定义的索引调用ensureIndex. 虽然很好用于开发,但建议在生产中禁用此行为,因为索引创建可能会导致显着的性能影响. 通过将模式的au ...

  10. Android中Animation 详细解读

    Animation从总体来说可以分为两类: 1.Tweened Animations:该类提供了旋转,移动,伸展,淡入淡出等效果 Tweened Animations也有四种类型: 1.     Al ...