码迷,mamicode.com
首页 > 其他好文 > 详细

GnuPG 的PGP使用

时间:2014-12-16 17:00:34      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   io   color   使用   sp   for   on   

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

$ gpg --gen-key
gpg (GnuPG) 2.0.14; Copyright (C) 2009 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:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = 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? (0) 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  -r test01 -e test.txt

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

 

GnuPG 的PGP使用

标签:style   blog   ar   io   color   使用   sp   for   on   

原文地址:http://www.cnblogs.com/got-my-way/p/4167371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!