【问题标题】:How to ignore newline in the end of openssl md5 command-line?如何忽略 openssl md5 命令行末尾的换行符?
【发布时间】:2018-12-20 11:52:40
【问题描述】:

我知道我们可以通过以下方式获得正确的输出:

回声-n 123456 | openssl md5
e10adc3949ba59abbe56e057f20f883e

printf 123456 | openssl md5
e10adc3949ba59abbe56e057f20f883e

printf 123456 > 文件.txt
openssl md5 文件.txt
e10adc3949ba59abbe56e057f20f883e

但是,我想知道我们是否可以在下面的命令行中使用额外的选项来解决它

openssl md5 f447b20a7fcbf53a5d5be013ea0b15af(这是不正确的)

【问题讨论】:

    标签: command-line openssl newline md5


    【解决方案1】:

    bash(和ksh93,和zsh)将总是在此处字符串的内容中添加一个换行符。除了显式过滤之外,没有其他办法。

    $ tr -d '\n' <<<'123456' | openssl md5
    (stdin)= e10adc3949ba59abbe56e057f20f883e
    

    【讨论】:

    • 经过大量尝试和搜索,我认为您是对的,非常感谢您的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-01
    相关资源
    最近更新 更多