torrentdht 0.1.1

DHT discovery with mTLS handshake handoff; optional BitTorrent when the host opts in
Documentation
pub type Checksum = u32;

pub fn checksum_block(data: &[u8]) -> Checksum {
    crc32c::crc32c(data)
}

pub fn verify_block_checksum(data: &[u8], expected: Checksum) -> bool {
    checksum_block(data) == expected
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn detects_corruption() {
        let data = b"hello block";
        let crc = checksum_block(data);
        assert!(verify_block_checksum(data, crc));
        assert!(!verify_block_checksum(b"hello blocx", crc));
    }
}