【问题标题】:OpenSSL "error reading input file" and "bad magic number"OpenSSL“错误读取输入文件”和“坏幻数”
【发布时间】:2013-07-07 17:33:25
【问题描述】:

我正在尝试加密一个简单的字符串“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

【问题讨论】:

    标签: openssl


    【解决方案1】:

    我想也许你的命令没有错,因为这些天我遇到了同样的问题。 TXT文件无法自动转入第二行,需要在密文末尾输入“Enter”并保存。然后,您可以再次输入您的命令。

    $ openssl enc -des -d -base64 -in atxt > a2.txt

    输入des-cbc解密密码:

    enter image description here

    【讨论】:

      【解决方案2】:

      马克,我看不出你的命令有什么问题。他们都在我的系统上运行良好。所以问题肯定出在其他地方。

      我建议尝试不同的 OpenSSL 安装/版本,或不同的系统。

      【讨论】:

      • 是的,我在 Ubuntu 上试过了,它工作正常。它在我的 Windows 7 系统上坏了。版本是git打包的openssl。
      • 马克,您可以尝试的另一个 Windows 版本的 OpenSSL 是 slproweb.com
      猜你喜欢
      • 2017-03-04
      • 2014-03-13
      • 2015-04-08
      • 2022-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-25
      相关资源
      最近更新 更多