pub fn fixed_xor(a: &[u8], b: &[u8]) -> Vec<u8> {
    assert_eq!(a.len(), b.len(), "two equal-length buffers");
    static CODES: &'static [u8] = b"0123456789abcdef";
    let mut xord = Vec::with_capacity(a.len());
    for (hex1, hex2) in a.chunks(2).zip(b.chunks(2)) {
        let a = unsafe { u8::from_str_radix(str::from_utf8_unchecked(hex1), 16).unwrap() };
        let b = unsafe { u8::from_str_radix(str::from_utf8_unchecked(hex2), 16).unwrap() };
        let c = a ^ b;
        xord.push(CODES[(c >> 4) as usize]);
        xord.push(CODES[(c & 0b1111) as usize]);
    }
    xord
}
/// takes two equal-length buffers and produces their XOR combination
takes two equal-length buffers and produces their XOR combination
takes two equal - length buffers and produces their XOR combination
pub fn fixed_xor(a: &[u8], b: &[u8]) -> Vec<u8> {
    assert_eq!(a.len(), b.len(), "two equal-length buffers");
    static CODES: &'static [u8] = b"0123456789abcdef";
    let mut xord = Vec::with_capacity(a.len());
    for (hex1, hex2) in a.chunks(2).zip(b.chunks(2)) {
        let a = unsafe { u8::from_str_radix(str::from_utf8_unchecked(hex1), 16).unwrap() };
        let b = unsafe { u8::from_str_radix(str::from_utf8_unchecked(hex2), 16).unwrap() };
        let c = a ^ b;
        xord.push(CODES[(c >> 4) as usize]);
        xord.push(CODES[(c & 0b1111) as usize]);
    }
    xord
}
pub fn fixed_xor ( a : & [ u8 ] , b : & [ u8 ] ) -> Vec < u8 > { assert_eq ! ( a len ( ) b len ( ) " " ) ; static CODES : & ' static [ u8 ] = b" " ; let mut xord = Vec :: with_capacity ( a . len ( ) ) ; for ( hex1 , hex2 ) in a . chunks ( 2 ) . zip ( b . chunks ( 2 ) ) { let a = unsafe { u8 :: from_str_radix ( str :: from_utf8_unchecked ( hex1 ) , 16 ) . unwrap ( ) } ; let b = unsafe { u8 :: from_str_radix ( str :: from_utf8_unchecked ( hex2 ) , 16 ) . unwrap ( ) } ; let c = a ^ b ; xord . push ( CODES [ ( c >> 4 ) as usize ] ) ; xord . push ( CODES [ ( c & 0b1111 ) as usize ] ) ; } xord }
takes two equal-length buffers and produces their XOR combination
takes two equal - length buffers and produces their XOR combination
a
&[u8]
b
&[u8]
a
&[u8]
b
&[u8]