我正在尝试加密一个简单的字符串“Hello world”。使用 OpenSSL 命令行工具。我已经尝试过使用 base64 和二进制进行加密。但是我遇到了一些无用的错误。
$ "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