💾 Archived View for 80h.dev › projects › gemserv › files › src › util.rs.gemini captured on 2022-06-12 at 00:48:51. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-03-01)
-=-=-=-=-=-=-
01 use url::form_urlencoded;
02
03 pub fn url_decode(url: &[u8]) -> String {
04 let decoded: String = form_urlencoded::parse(url)
05 .map(|(key, val)| [key, val].concat())
06 .collect();
07 return decoded
08 }
09
10 pub fn fingerhex(x509: &openssl::x509::X509) -> String {
11 let finger = match x509.digest(openssl::hash::MessageDigest::sha256()) {
12 Ok(f) => f,
13 _ => return "".to_string(),
14 };
15 let mut hex: String = String::from("SHA256:");
16 for f in finger.as_ref() {
17 hex.push_str(&format!("{:02X}", f));
18 }
19 hex
20 }