YAMAGUCHI::weblog

海水パンツとゴーグルで、巨万の富を築きました。カリブの怪物、フリーアルバイター瞳です。

macOSでパスワード付きzipを作成する

はじめに

いつから行われているのかわからないけれど、IT業界では「パスワード ハ オッテ ゴレンラクイタシマス」という呪文を唱え、パスワード付きzipとそのパスワードを2通のメールで送る慣習がある。普段は自分からそういうzipファイルを送ることはないのだけれども、今日たまたまどうしてもそうする必要があった。

zipcloak

で、調べてみたら、macOSでもzipcloakコマンドというのがあって、それを使えばパスワード付きzipを作れるということを今日知った。情弱乙。

$ zip -r path-to-dir/ archive.zip
$ zipcloak archive.zip
Enter password:
Verify password:

zipコマンドでまず普通のzipファイルを作成して、zipcloakコマンドでそれをキーフレーズで暗号化するという流れ。地味に便利だった。

zip -e

記事を公開してから力武さんにzipコマンド自体のオプションを教えてもらった。

$ man zip
...
       -e
       --encrypt
              Encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt (this will not be echoed; if standard error is not a  tty,  zip  will  exit
              with an error).  The password prompt is repeated to save the user from typing errors.

ほんとだ、情弱すぎた。というかmanを読んでないのが悪い。

$ zip -e -r path-to-dir/ archive.zip
Enter password:
Verify password:

できた。