MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / mac_key_bytes

Function mac_key_bytes

atomic-agent/src/turn/capture.rs:203–217  ·  view source on GitHub ↗

Decode the hex MAC key into exactly 32 bytes.

(key_hex: &str)

Source from the content-addressed store, hash-verified

201
202/// Decode the hex MAC key into exactly 32 bytes.
203fn 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///

Callers 1

macMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected