noraworld / scraps

Just my scraps, like Zenn scraps feature
0 stars 0 forks source link

ファイルの暗号化と復号 #44

Open noraworld opened 1 year ago

noraworld commented 1 year ago

鍵生成

openssl genrsa -aes256 -out key.pem 4096

X.509 証明書生成 (自己署名証明書)

openssl req -new -x509 -key key.pem -out cert5.pem -days 36500 -subj /CN="Kosuke Aoki"

暗号化

openssl smime -aes256 -binary -encrypt -in naisyo.txt -out naisyo.txt.enc cert.pem

復号

openssl smime -decrypt -in naisyo.txt.enc -out naisyo.txt -inkey key.pem

参考

noraworld commented 1 year ago
Country Name (2 letter code) []:
State or Province Name (full name) []:
Locality Name (eg, city) []:
Organization Name (eg, company) []:
Organizational Unit Name (eg, section) []:
Common Name (eg, fully qualified host name) []:
Email Address []:
noraworld commented 1 year ago
openssl x509 -noout -subject -dates -in cert.pem 
subject= /CN=foo
notBefore=Jan  2 20:00:07 2023 GMT
notAfter=Feb  1 20:00:07 2023 GMT
noraworld commented 1 year ago
noraworld commented 1 year ago

gpg のほうで大容量ファイルの暗号化・復号を試そうとしたらディスクがいっぱいになってしまったのでいったんバックアップ作業に戻る。