Skip to content
Snippets Groups Projects
Verified Commit 9122d1a2 authored by Korben Tompkin's avatar Korben Tompkin :mortar_board:
Browse files

feat(server): Initial (inefficient) hashing logic

parent 07012f5a
No related branches found
No related tags found
1 merge request!3feat(server): Server implementation
......@@ -52,11 +52,17 @@ async fn search(Path(query): Path<String>) -> Result<Json<Value>, StatusCode> {
}
},
};
let ids: HashMap<&String, &String> = ed.db.iter().filter(|(k, _)| k.contains(&query)).collect();
let ids: HashMap<&String, &String> = ed
.db
.iter()
.enumerate()
.filter(|(i, (k, _))| k.contains(&hash(format!("{}{}", query, i))))
.map(|(_, (k, v))| (k, v))
.collect();
Ok(Json(json!(ids)))
}
async fn hash(plaintext: String) -> String {
fn hash(plaintext: String) -> String {
let mut hf = Tiger::new();
hf.update(plaintext.as_bytes());
hex::encode(hf.finalize().as_slice())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment