Repository navigation
samlan@saml-debian:~/cryptography$ python3 encrypt.py
AES-GCM + Argon2id(Associated Data=python pycryptodome cipher-deuj2)加密
AES-GCM 加密
請輸入要加密的檔案的路徑:n7st.png
密碼:
密碼過弱,建議 5-40 字元,含大小寫字母、數字及特殊符號,按enter來更改, 輸入weak來確定使用此弱密碼:weak
密文檔案路徑:n7st-aes-arg.png.enc
加密完成,密文檔案路徑: n7st-aes-arg.png.enc
samlan@saml-debian:~/cryptography$ cp n7st-aes-arg.png.enc n7st-aes-arg.png-tamper.enc
samlan@saml-debian:~/cryptography$ sha384sum n7st-aes-arg.png.enc n7st-aes-arg.png-tamper.enc
4f20c4cae4877413a007ac72ecc55928d8205fc4306dead0e59be224d6bad674eddb4b08df21f4ec80271c150e14eaab n7st-aes-arg.png.enc
4f20c4cae4877413a007ac72ecc55928d8205fc4306dead0e59be224d6bad674eddb4b08df21f4ec80271c150e14eaab n7st-aes-arg.png-tamper.enc
samlan@saml-debian:~/cryptography$ perl -pi -e 'BEGIN { sysopen(F, $ARGV[0], 2); sysseek(F, -1, 2); sysread(F, $b, 1); sysseek(F, -1, 2); syswrite(F, $b ^ "\x01"); exit }' n7st-aes-arg.png-tamper.enc
samlan@saml-debian:~/cryptography$ tail -c 4 n7st-aes-arg.png.enc | xxd -b
00000000: 01110110 10111001 01101111 10101110 v.o.
samlan@saml-debian:~/cryptography$ tail -c 4 n7st-aes-arg.png-tamper.enc | xxd -b
00000000: 01110110 10111001 01101111 10101111
samlan@saml-debian:~/cryptography$ python3 decrypt.py
AES-GCM 256 + Argon2id(Associated Data=python pycryptodome cipher-deuj2)解密
請輸入要解密的檔案路徑:n7st-aes-arg.png-tamper.enc
密碼:
警告!訊息遭竄改!
解密錯誤。
錯誤碼:MAC check failed
檢查是否輸入錯誤,或訊息遭竄改。
samlan@saml-debian:~/cryptography$ sha384sum n7st-aes-arg.png-tamper.enc n7st-aes-arg.png.enc
86a2e3a4595a143d854580fc1f48a549c4b4d2a373eb00613f1e0ca61b46af3507675bf40d5e85339e35d5ac99ebb80d n7st-aes-arg.png-tamper.enc
4f20c4cae4877413a007ac72ecc55928d8205fc4306dead0e59be224d6bad674eddb4b08df21f4ec80271c150e14eaab n7st-aes-arg.png.enc
samlan@saml-debian:~/cryptography$