示例#1
0
uint8_vec xor_vec(uint8_vec const &a, uint8_vec const &b) {
    uint8_vec v;
    v.reserve(std::min(a.size(), b.size()));

    for (uint8_vec::const_iterator i = a.begin(), j = b.begin(); i != a.end() && j != b.end(); ++i, ++j) {
        v.push_back(*i ^ *j);
    }

    return v;
}
示例#2
0
std::string codes_to_hex(uint8_vec const &v) {
    std::stringstream ss;
    ss << std::hex;

    for (uint8_vec::const_iterator it = v.begin(); it != v.end(); ++it) {
        ss << std::setw(2) << std::setfill('0') << (int) *it;
    }

    return ss.str();
}