1
0
Fork 0
forked from wry/wry

autocommit 2022-02-27 01:35:49 CET

This commit is contained in:
Julian Orth 2022-02-27 01:35:49 +01:00
parent 6e466360a8
commit db88f2db42
26 changed files with 2696 additions and 6 deletions

15
src/utils/hex.rs Normal file
View file

@ -0,0 +1,15 @@
pub fn to_hex(b: &str) -> String {
let mut s = String::with_capacity(b.len() * 2);
for &b in b.as_bytes() {
s.push(nibble_to_hex(b >> 4) as char);
s.push(nibble_to_hex(b & 7) as char);
}
s
}
fn nibble_to_hex(n: u8) -> u8 {
match n {
n @ 0..=9 => b'0' + n,
n => b'a' + n,
}
}