Skip to content

Instantly share code, notes, and snippets.

@ryu1
Created April 30, 2023 08:49
Show Gist options
  • Save ryu1/84bfd0b144b601156004552ee3f97769 to your computer and use it in GitHub Desktop.
Save ryu1/84bfd0b144b601156004552ee3f97769 to your computer and use it in GitHub Desktop.
Big file encryption
# 秘密鍵を作成する(パスフレーズ有り)
openssl genrsa -aes256 4096 > private.key
# X.509 証明書生成 (自己署名証明書)
openssl req -new -x509 -key private.key -out cert.pem -days 36500 -subj /CN="sample"
# 証明書情報の確認
openssl x509 -noout -subject -dates -in cert.pem
# 暗号化
openssl smime \
-encrypt \
-binary \
-aes-256-cbc \
-in largefile.bin \
-out largefile.bin.encrypted \
-outform DER \
cert.pem
# 復号化
openssl smime \
-decrypt \
-in largefile.bin.encrypted \
-binary \
-inform DER \
-inkey private.key \
-out largefile.bin.dat.decrypted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment