tk-rs 1.0.0

A Rust library for Turnkey signing
Documentation
1
2
3
4
5
6
7
8
9
10
11
pub fn hex_to_bytes(hex: &str) -> Result<Vec<u8>, anyhow::Error> {
    (0..hex.len())
        .step_by(2)
        .map(|i| u8::from_str_radix(&hex[i..i + 2], 16))
        .collect::<Result<Vec<_>, _>>()
        .map_err(|e| anyhow::anyhow!(e.to_string()))
}

pub fn bytes_to_hex(bytes: &[u8]) -> Result<String, anyhow::Error> {
    Ok(bytes.iter().map(|byte| format!("{:02x}", byte)).collect())
}