22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GnuPGやOpenSSLでディレクトリを暗号化

Last updated at Posted at 2013-01-13

はじめに

GnuPGOpenSSL共通鍵暗号 方式で, アルゴリズムは AES256 を使う.

なお, gpgでアルゴリズムを指定するには, --cipher-algoオプションを使うが,
あらかじめ設定ファイルに追記しておけば, オプションを省略できる.

~/.gnupg/gpg.conf
cipher-algo aes256

ディレクトリの暗号化・復号化

GnuPG

tar cf - foo | gpg -c -o foo.tar.gpg # 暗号化
gpg -o- foo.tar.gpg | tar xvf - # 復号化

さらに, GnuPG付属のgpg-zipスクリプトを用いれば, 簡潔に書ける.

gpg-zip -o foo.tar.gpg -c foo # 暗号化
gpg-zip -d foo.tar.gpg # 復号化

OpenSSL

tar cf - foo | openssl aes-256-cbc -e -out foo.tar.enc # 暗号化
openssl aes-256-cbc -d -in foo.tar.enc | tar xvf - # 復号化

参考: 単一ファイルの暗号化・復号化

比較のため, それぞれ以下に載せる.

GnuPG

gpg -c bar.txt # 暗号化
gpg bar.txt.gpg # 復号化

OpenSSL

openssl aes-256-cbc -e -in bar.txt -out bar.txt.enc # 暗号化
openssl aes-256-cbc -d -in bar.txt.enc -out bar.txt # 復号化
22
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?