SQL SQLite 中的 MD5 函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5079386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 09:24:26  来源:igfitidea点击:

MD5 function in SQLite

sqlsqlitemd5user-defined-functions

提问by Rory

I am trying to port some sql from MySQL to SQLite, however we use mysql's md5()function, which doesn't exist in sqlite.

我试图将一些 sql 从 MySQL 移植到 SQLite,但是我们使用了 mysql 的md5()函数,它在 sqlite 中不存在。

I've seen references to people recompiling sqlite to include this function, and i think it's possible to include user defined functions in sqlite (right?). So how do I go about adding md5() to sqlite? I'd rather not have to recompile the sqlite installed by my package manager, is it possible to have md5 without doing this?

我已经看到人们重新编译 sqlite 以包含此函数的参考,我认为可以在 sqlite 中包含用户定义的函数(对吗?)。那么如何将 md5() 添加到 sqlite 呢?我宁愿不必重新编译由我的包管理器安装的 sqlite,是否可以在不这样做的情况下使用 md5?

回答by Tim Tessier

I have created an extension for sqlite using openssl functions. You may check it out here!

我使用 openssl 函数为 sqlite 创建了一个扩展。你可以在这里查看

Be forewarned, you need a compiler and some knowledge of how to use one. I can provide some assistance if you need - just post a comment.

预先警告,你需要一个编译器和一些如何使用它的知识。如果您需要,我可以提供一些帮助 - 只需发表评论。

回答by Martin Buberl

SQLite doesn't have any built-in hashing functionality. But as you correctly said you could define a user function. See this SO answer for more details:

SQLite 没有任何内置的散列功能。但是正如您所说,您可以定义用户功能。有关更多详细信息,请参阅此 SO 答案:

Hope that helps!

希望有帮助!