在 erlang 中计算 MD5 哈希值
Computing MD5 hashes in erlang
我一直在尝试用 erlang 编写 md5-digest 算法,但不知道如何实现这一步,
1. creating 16 octet MD5 hash of X where X is a string.
有人可以帮忙吗?
是不是这个意思:
Create a 16 byte(32-hex digits) of base - 8(octet) which is md5 of X. ?
谢谢!
使用crypto
模块和hash
函数,可以计算出16字节摘要算法的MD5
crypto:hash(Type, Data) -> Digest
Type = md5
Data = iodata()
Digest = binary()
它得到一个 md5
原子作为类型和一个 iodata()
作为数据,以及 returns 一个 binary()
作为摘要。下面的代码片段是一个简单的例子:
crypto:hash(md5, "put-your-string-here").
查看 crypto documentation 了解更多信息。
同样是将返回的二进制值转为十六进制字符串,标准库中没有这个函数,不过简单的几行代码,在this thread.
中有很好的解释
这个来自 epop 包的 md5 module 计算 md5 和 returns 它作为一个十六进制字符串。
epop_md5:string("put-your-string-here").
我一直在尝试用 erlang 编写 md5-digest 算法,但不知道如何实现这一步,
1. creating 16 octet MD5 hash of X where X is a string.
有人可以帮忙吗?
是不是这个意思:
Create a 16 byte(32-hex digits) of base - 8(octet) which is md5 of X. ?
谢谢!
使用crypto
模块和hash
函数,可以计算出16字节摘要算法的MD5
crypto:hash(Type, Data) -> Digest
Type = md5 Data = iodata() Digest = binary()
它得到一个 md5
原子作为类型和一个 iodata()
作为数据,以及 returns 一个 binary()
作为摘要。下面的代码片段是一个简单的例子:
crypto:hash(md5, "put-your-string-here").
查看 crypto documentation 了解更多信息。
同样是将返回的二进制值转为十六进制字符串,标准库中没有这个函数,不过简单的几行代码,在this thread.
中有很好的解释这个来自 epop 包的 md5 module 计算 md5 和 returns 它作为一个十六进制字符串。
epop_md5:string("put-your-string-here").