0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ファイルを暗号化したい.初めてのOpenssl.(Windows版)

Last updated at Posted at 2022-06-06

Intro

パソコンに保存したファイルは簡単に第三者に閲覧可能である.OpenSSLを使用すれば,windowsやLinuxで共有したファイルを容易に鍵をかけることができる.今回はPowerShellを使った暗号化の1例を紹介する.ファイルの暗号化だけでなく,ディレクトリ(フォルダ)の暗号化も行いたいので,圧縮(Zip)してから暗号化する.一連の手順を備忘録として残しておく.

暗号化してから圧縮したばあい,圧縮率は低くなる.
圧縮と暗号化を同時に利用することで,ファイル名がわからなくなるのでセキュアになる.
圧縮ファイルだとわからなくすることでよりセキュアになる.

Install OpenSSL for Windows

  • Win64 OpenSSl v3.033 Light

image.png

Command

あるフォルダをまるごと暗号化したい場合の手順は次の通りある.

  • 対象フォルダの圧縮
  • 圧縮フォルダの暗号化
  • 圧縮フォルダの復号
  • 圧縮フォルダの解凍
PS
PS > Compress-Archive -path .\1_hoge -DestinationPath .\2_hoge.zip -F
PS >  openssl enc -e -aes-256-cbc -base64 -pbkdf2 -md sha256 -salt -k pass -in .\2_hoge.zip -out .\3_hoge.zip.enc
PS >  openssl enc -d -aes-256-cbc -base64 -pbkdf2 -md sha256 -salt -k pass -in .\3_hoge.zip.enc -out .\4_hoge.zip
PS > Expand-Archive -Path .\4_hoge.zip -DestinationPath ./5_hoge

Results

無事にフォルダの中身の暗号化と復号ができました.

image.png

References

以下のサイトを参考にしました.

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?