next up previous contents
Next: 簽章驗證 Up: GnuPG Previous: 以匯入的公鑰加密   Contents

數位簽章

  1. 對 demo.txt 進行明文數位簽章。
    [deyu1@kvm8 ~]$ gpg --clearsign demo.txt
    
    You need a passphrase to unlock the secret key for
    user: "abc123 (ABC) <abc123@csie.cyut.edu.tw>"
    2048-bit RSA key, ID A98B198E, created 2014-05-26
    
  2. 簽章後檔案預設為檔名.asc,也就是 demo.txt.asc,檔案以 ASCII 碼存檔。
    [deyu1@kvm8 ~]$ cat demo.txt.asc 
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    
    abc123
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2.0.14 (GNU/Linux)
    
    iQEcBAEBAgAGBQJTgsY1AAoJEGKwGRGpixmOF9MIAKCgWrK7sgqJqUsMOutKIOQT
    aQXER43zTXQPUHQgB88q8UX2HdObfNUgG70oSpqLhNEloTYEF66sTVQ6143NDCR1
    NwjdK3WNH9KhBHhy+TyYKx7vOWhyugBI/ePEPzkrbqrMiMOiAB+S4bWsFCGVPTOb
    iiyeUq71AdXLveXmfS5qQzR3jGaQy+K9WDEnVVDhMoz2Sv9BbNBkVahs4gMSO9+y
    aBu4L4h4bBcjesQV42IebUjNwDkl76VxkL8m0XXlip8u9pwELjsl+dfCxS//9qK0
    oc0duZIGnqboZqI75v9gHqhRsmxUlnWs9H67m1X7inb9iy7xqtPEHGBat0tRaB8=
    =Y+e7
    -----END PGP SIGNATURE-----
    
  3. 驗證簽章。
    [deyu1@kvm8 ~]$ gpg --verify demo.txt.asc
    gpg: Signature made Mon 26 May 2014 12:42:29 PM CST using RSA key ID A98B198E
    gpg: Good signature from "abc123 (ABC) <abc123@csie.cyut.edu.tw>"
    
  4. 對 demo.txt 進行數位簽章。
    [deyu1@kvm8 ~]$ gpg --sign demo.txt
    
    You need a passphrase to unlock the secret key for
    user: "abc123 (ABC) <abc123@csie.cyut.edu.tw>"
    2048-bit RSA key, ID A98B198E, created 2014-05-26
    
  5. 簽章檔預設檔名加上 gpg 附檔名,也就是 demo.txt.gpg,檔案不以 ASCII 存檔。
    [deyu1@kvm8 ~]$ cat demo.txt.gpg
    .............................
    
  6. 驗證簽章。
    [deyu1@kvm8 ~]$ gpg --verify demo.txt.gpg 
    gpg: Signature made Mon 26 May 2014 12:51:59 PM CST using RSA key ID A98B198E
    gpg: Good signature from "abc123 (ABC) <abc123@csie.cyut.edu.tw>"
    



2017-10-27