问题描述
在平行的几个区议会的工作和需要散列口令来初始化一些记录。在 MS SQL服务器
有方便的功能,允许散列动态:
Working with several DBs in parallel and need to initialize some records with hashed passwords. In MS SQL server
there are handy functions that allow to hash on the fly:
HashBytes('SHA1', CONVERT(nvarchar(32), N'admin'))
是否有与的SQLite
?
如果不是,这是最简单的解决方法(如选择从 SQL服务器
并以某种方式将其插入的SQLite
表)?
If not, which is the easiest workaround (such as select from SQL server
and somehow insert it into SQLite
tables)?
在preferred散列算法 SHA1
和密码存储在 BLOB
列。
The preferred hashing algorithm is SHA1
and the passwords are stored in a BLOB
column.
更新:在当前项目中,我使用C#语言
Update: I use C# language in the current project.
推荐答案
有是内置的SQLite3没有这种功能。
There is no such function built into SQLite3.
但是你可以如定义用户的功能与如果你使用的C接口,并实现SHA-1这一点。 (但如果你有一个可编程接口也许你可以只SHA-1的SQL引擎外的密码。)
But you could define a user function e.g. with sqlite3_create_function
if you're using the C interface, and implement SHA-1 with that. (But if you're having a programmable interface perhaps you could just SHA-1 the password outside of the SQL engine.)
您也可以尝试查找/创建扩展和负载,但我没有这些经验。
You could also try to find / create an extension and load with the load_extension
function, but I don't have experience on that.
编辑:
- 见this回答的 SQLiteFunction简单不工作的如何在C#中定义与
System.Data.SQLite
自定义函数。 - 使用System.Security.Cryptography.SHA1计算SHA-1散列。
- See this answer on SQLiteFunction Simple Not Working for how to define a custom function with
System.Data.SQLite
in C#. - Use System.Security.Cryptography.SHA1 to compute the SHA-1 hash.
这篇关于SHA1散列SQLite中:怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!