如何创建MD5哈希在bash在Mac OS X [英] How to create md5 hash in bash in Mac OS X

查看:147
本文介绍了如何创建MD5哈希在bash在Mac OS X的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么能对使用庆典 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.

推荐答案

这应该工作 -

[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

这篇关于如何创建MD5哈希在bash在Mac OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆