zoukankan      html  css  js  c++  java
  • GnuPG 的PGP使用

    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 -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
  • 相关阅读:
    Codeforces Round #229
    A Funny Game(博弈论)
    01背包模板
    一月24日新生冬季练习赛解题报告H.排列问题
    一月24日新生冬季练习赛解题报告F.棋盘
    POJ 2240Arbitrage
    POJ 3660Cow Contest
    POJ 3259Wormholes
    POJ 1860Currency Exchange
    HDU 4027Can you answer these queries?
  • 原文地址:https://www.cnblogs.com/got-my-way/p/4167371.html
Copyright © 2011-2022 走看看