GnuPGを使ってみたメモです。
少し古いですが参考にしました:
gpg --gen-key
暗号化 + 署名生成(受け取る相手が"UID"を想定):
gpg -se -r "UID" -o encrypted.dat plain.txt
「"UID"」の部分は、鍵を生成した時の"Real name", "Email address", "Comment"のどれか or フル指定。
例:
Real name: Foo Bar Email address: foobar@example.com Comment: mycomment You selected this USER-ID: "Foo Bar (mycomment) <foobar@example.com>"
になるので、
"Foo Bar"
とか
"mycomment"
とか、厳密に一致させたい時は
"=Foo Bar (mycomment) <foobar@example.com>"
みたいに"UID"を指定できる。スペースが入って無ければダブルクォートで囲まなくとも平気かも。
UIDについての正確なドキュメントは下記参照:
復号化(署名検証は自動処理):
gpg encrypted.dat gpg -o plain.txt encrypted.dat
PC1で生成した自分の公開鍵・秘密鍵をPC2に複製する:
公開鍵・秘密鍵のエキスポート
gpg -o public.key --export "UID" gpg -o secret.key --export-secret-key "UID" gpg --export-ownertrust > ownertrust.dat
公開鍵・秘密鍵のインポート
gpg --import public.key gpg --import --allow-secret-key-import secret.key gpg --import-ownertrust ownertrust.dat