【问题标题】:Assign the output of a hashing function to a variable [duplicate]将散列函数的输出分配给变量[重复]
【发布时间】:2014-04-25 01:31:39
【问题描述】:

我需要自动创建 sha512 哈希。我对 bash 脚本还很陌生,而且我读过的所有内容都没有对我有太大帮助。

这一行给了我正确的哈希值并且没有给 $hashed 赋值

echo -n thingToHash | openssl dgst -sha512 -out $hashed;

这一行给了我错误的哈希值,也没有给 $hashed 赋值

$hashed= thingToHash | openssl dgst -sha512;

我已经尝试了其他几种类似的结果。

【问题讨论】:

    标签: bash hash openssl


    【解决方案1】:

    分配给变量:var=$(app_a | app_b)

    美元符号仅用于读取值。

    在你的情况下:

    hashed=$(echo "blah" | openssl dgst -sha512)

    然后读取哈希值:

    echo $hashed

    【讨论】:

      猜你喜欢
      • 2017-09-28
      • 1970-01-01
      • 2015-04-14
      • 1970-01-01
      • 2014-01-08
      • 2012-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多