next up previous contents
Next: 簽章驗證 Up: GnuPG Previous: 數位簽章-文字檔   Contents

數位簽章-pdf檔

  1. 對 demo.pdf 進行數位簽章,輸入 passphrase。
    [dywang@dywmac ~]$ gpg --sign --output=demo.pdf.sig demo.pdf
    
    You need a passphrase to unlock the secret key for
    user: "De-Yu Wang (rhcx) <dywang7@gamil.com>"
    2048-bit RSA key, ID 907CE30E, created 2013-06-20
    
    can't connect to `/home/dywang/.gnupg/S.gpg-agent': 
    No such file or directory
    
    (pinentry-gtk-2:9349): GLib-GObject-CRITICAL **: 
    Object class GtkSecureEntry doesn't implement property 
    'editing-canceled' from interface 'GtkCellEditable'
    
  2. 產生 demo.pdf.sig。
    [dywang@dywmac ~]$ ll demo.pdf*
    -rw-rw-r--. 1 dywang dywang 1574142 May 31 18:59 demo.pdf
    -rw-rw-r--. 1 dywang dywang 1574045 May 31 19:09 demo.pdf.sig
    
  3. 驗證 demo.pdf.sig 為 De-Yu Wang 簽章。
    [dywang@dywmac ~]$ gpg --verify demo.pdf.sig 
    gpg: Signature made Thu 31 May 2018 07:09:51 PM CST using RSA key ID 907CE30E
    gpg: Good signature from "De-Yu Wang (rhcx) <dywang7@gamil.com>"
    
  4. 解密 demo.pdf.sig,存成 a.pdf。
    [dywang@dywmac ~]$ gpg --output a.pdf --decrypt demo.pdf.sig 
    gpg: Signature made Thu 31 May 2018 07:09:51 PM CST using RSA key ID 907CE30E
    gpg: Good signature from "De-Yu Wang (rhcx) <dywang7@gamil.com>"
    
  5. 比對 a.pdf 與原始檔 demo.pdf 無差異。
    [dywang@dywmac ~]$ diff demo.pdf a.pdf
    



2018-06-16