【问题标题】:How to Base64 encode a MD5 binary string using shell commands?如何使用 shell 命令对 MD5 二进制字符串进行 Base64 编码?
【发布时间】:2015-10-05 03:30:11
【问题描述】:

我需要在 Unix (Solaris) 中运行这个 Linux 命令:

echo -n foo | openssl dgst -md5 -binary | openssl enc -base64

但它只是给我一个“找不到命令”错误。我完全是 Unix/Linux 的新手,所以我不知道这是否可能,或者是否有解决方法可以达到相同的结果。

非常感谢您。

【问题讨论】:

标签: unix openssl md5


【解决方案1】:

我刚刚在 Ubuntu Linux 下执行了你的命令,它可以工作。结果如下:

$ echo -n foo | openssl dgst -md5 -binary | openssl enc -base64
rL0Y20zC+Fzt72VPzMSk2A==
$ 

也许您的 Solaris 发行版中没有安装某些东西?喜欢openssl。这个命令看起来不错。

【讨论】:

    【解决方案2】:

    openssl 不在 PATH 中。 寻找 openssl 命令的位置(find / -executable -type f -name "openssl" 2> /dev/null 可能有帮助)。 它可能在/usr/sfw/bin/usr/bin//usr/local/bin/opt 中的目录之一下。

    找到位置后,将其添加到 PATH

    export PATH=$PATH:/usr/sfw/bin
    

    或使用完整路径调用openssl 命令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-03
      • 2012-08-23
      • 2012-09-01
      • 2014-03-25
      • 1970-01-01
      • 1970-01-01
      • 2011-11-29
      • 1970-01-01
      相关资源
      最近更新 更多