md5的纯Lua实现
md5哈希算法有纯lua实现吗?一个不依赖任何 c 或外部库的?有一些 javascript 实现不依赖于 c 或任何东西,所以用 lua 应该可以实现。 谢谢!
Is there a pure lua implementation of the md5 hashing algorithm? One that doesn't rely on any c or external libraries? There's javascript implementations that don't rely on c or anything, so it ought to be possible with lua.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我结合了前面提到的需要bitlib的lua MD5库并添加到LuaBit中,使其成为一个纯lua实现。
作为一个额外的好处,它的结构方式使其可以在 redis lua 脚本环境中工作。
请注意,与其他非纯 lua 实现相比,它非常慢。
它可在本要点中找到。
I combined the mentioned lua MD5 library that required bitlib and added in LuaBit to make it a pure lua implementation.
As an additional benefit it's structured in such a way that it will work inside of the redis lua scripting environment.
Please note that it is extremely slow compared to other non pure lua based implementations.
It is available in this gist.
http://equi4.com/md5/md5calc.lua 但这仍然需要 库。
http://equi4.com/md5/md5calc.lua but that still requires a lib.
这里有一个旧的,但它需要 bitlib。
There's an old one here but it requires bitlib.
我改进了 @Adam Baldwin 的解决方案,并制作了一个用纯 Lua 计算 md5 和的库,没有外部依赖项,也没有 C:
https://github.com/kikito/md5.lua
变更摘要:
md5.sum
和md5.sumhex,其工作方式与 Kepler 库中的对应部分完全相同,但仅在 Lua 中实现。
目前我不需要
md5.crypt
和md5.decrypt
,所以我还没有实现它们。但我会接受拉取请求:)I've refined @Adam Baldwin's solution and made a library that calculates md5 sums in pure Lua, with no external dependencies and no C:
https://github.com/kikito/md5.lua
Summary of changes:
md5.sum
andmd5.sumhex
, that work exactly like their counterparts in the Kepler library, but are implemented in Lua alone.For now I don't need
md5.crypt
andmd5.decrypt
, so I have not implemented those. But I will accept pull requests :)