Use this crate to add various hash functions to SQLite, including MD5, SHA1, SHA256, and SHA512.
This crate uses rusqlite to add user-defined scalar functions using static linking. Eventually this crate may also support dynamic extension loading (PRs welcome).
```rust use sqlitehashes::{registersha256_function, rusqlite::Connection};
fn main() { let db = Connection::openinmemory().unwrap(); registersha256function(&db).unwrap();
let sql = "SELECT hex(sha256('password'))"; let hash: String = db.queryrowandthen(&sql, [], |r| r.get(0)).unwrap(); asserteq!(hash, "5E884898DA28047151D0E56F8DC6292773603D0D6AABBDD62A11EF721D1542D8"); } ```
By default, this crate will compile with all hash functions. You can enable just the ones you need to reduce compile time.
toml
[dependencies]
sqlite-hashes = { version = "0.1", default-features = false, features = ["sha256"] }
make
. Install it with cargo install just
.git push
, it will run a few validations, including cargo fmt
, cargo clippy
, and cargo test
. Use git push --no-verify
to skip these checks.Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.