如何忽略 openssl md5 命令行末尾的换行符?

How to ignore newline in the end of openssl md5 command-line?

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

echo -n 123456 | openssl md5
e10adc3949ba59abbe56e057f20f883e

printf 123456 | openssl md5
e10adc3949ba59abbe56e057f20f883e

printf 123456 > file.txt
openssl md5 file.txt
e10adc3949ba59abbe56e057f20f883e

但是,我想知道我们能否在下面的命令行中使用额外的选项来解决这个问题

openssl md5 <<< '123456'
f447b20a7fcbf53a5d5be013ea0b15af( this is incorrect)

bash(和ksh93,以及zsh)将总是在here-string的内容上附加一个换行符。除了明确地过滤掉它之外没有办法解决这个问题。

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