• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

创建MD5哈希在bash在Mac OS X

用户头像
it1352
帮助1

问题说明

你怎么能对使用庆典 A的MAC字符串创建MD5哈希? 的md5sum 并不在我的环境中。我做了一个为MD5,但我感到困惑的是什么确实做到了。

How can you create an md5 hash for a string on a mac using bash? md5sum does not exist in my environment. I did a man for md5 but I'm confused about what that really does.

md5 "string"

不返回的哈希值。

does not return a hash.

正确答案

#1

这应该工作 -

[jaypal:~/Temp] echo "this will be encrypted" | md5
72caf9daf910b5ef86796f74c20b7e0b

或者如果你preFER 这里字符串标记然后 -

[jaypal:~/Temp] md5 <<< 'this will be encrypted'
72caf9daf910b5ef86796f74c20b7e0b

更新:

页,您可以玩弄任何下列选项

UPDATE:

Per the man page, you can play around with any of the following options

-s string
        Print a checksum of the given string.

-p      Echo stdin to stdout and append the checksum to stdout.

-q      Quiet mode - only the checksum is printed out.  Overrides the -r option.


[jaypal:~/Temp] md5 -s 'this will be encrypted'
MD5 ("this will be encrypted") = 502810f799de274ff7840a1549cd028a

[jaypal:~/Temp] md5 -qs 'this will be encrypted'
502810f799de274ff7840a1549cd028a

注意:MD5始终产生相同的哈希值。找到从上面给出的例子中的输出不同的原因是由于已经在评论已取得的点。前两个例子使用尾随换行字符产生哈希值。为了避免这种情况,你可以使用:

Note: MD5 always produces the same hash. The reason you find the output different from the example given above is due to a point that has been made in the comments. The first two examples use the trailing newline character to produce the hash. To avoid that, you can use:

[jaypal:~/Temp] echo -n "this will be encrypted" | md5
502810f799de274ff7840a1549cd028a

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfhaea
系列文章
更多 icon
同类精品
更多 icon
继续加载