Decode the hex MAC key into exactly 32 bytes.
(key_hex: &str)
| 201 | |
| 202 | /// Decode the hex MAC key into exactly 32 bytes. |
| 203 | fn mac_key_bytes(key_hex: &str) -> [u8; 32] { |
| 204 | let mut key = [0u8; 32]; |
| 205 | let mut byte = 0u8; |
| 206 | let mut filled = 0usize; |
| 207 | for (index, character) in key_hex.chars().enumerate() { |
| 208 | let nibble = character.to_digit(16).unwrap_or(0) as u8; |
| 209 | if index % 2 == 0 { |
| 210 | byte = nibble << 4; |
| 211 | } else if filled < 32 { |
| 212 | key[filled] = byte | nibble; |
| 213 | filled += 1; |
| 214 | } |
| 215 | } |
| 216 | key |
| 217 | } |
| 218 | |
| 219 | /// Build a capture from the session and the exact git observation token. |
| 220 | /// |