我試圖加密一個簡單的字符串「Hello world」。使用OpenSSL命令行工具。我已經試過同時使用Base64和二進制文件都加密。但我得到一些無益的錯誤。OpenSSL「錯誤讀取輸入文件」和「壞的幻數」
$ "Hello world." > plain.txt
$ openssl enc -aes-128-ecb -e -base64 -in plain.txt > enc.txt
enter aes-128-ecb encryption password:
Verifying - enter aes-128-ecb encryption password:
$ cat enc.txt
U2FsdGVkX18ZoAY34fL2aMO0Bu5AJnewemhfiBmSL1IJujqOtpJm7V0C+Tt83egJ
$ openssl enc -aes-128-ecb -d -base64 -in enc.txt > out.txt
enter aes-128-ecb decryption password:
error reading input file
然後我嘗試二進制
$ "Hello world." > plain.txt
$ openssl enc -aes-128-ecb -e -in plain.txt > enc.bin
enter aes-128-ecb encryption password:
Verifying - enter aes-128-ecb encryption password:
$ openssl enc -aes-128-ecb -d -in enc.bin > out.txt
enter aes-128-ecb decryption password:
bad magic number
是的,我試圖在Ubuntu和有效。它在我的Windows 7系統上壞掉了。該版本是被包裝使用Git OpenSSL的。 – Mark
Mark,您可以嘗試的另一個Windows版本的OpenSSL是[slproweb.com](http://slproweb.com/products/Win32OpenSSL.html)。 – gtrig