コード例 #1
0
ファイル: main.cpp プロジェクト: da-eto-ya/crypto-exercises
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
ファイル: main.cpp プロジェクト: da-eto-ya/crypto-exercises
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();
}
コード例 #3
0
ファイル: vogl_ktx_texture.cpp プロジェクト: IanAtLunarG/vogl
    bool ktx_texture::get_key_value_data(const char *pKey, uint8_vec &data) const
    {
        const uint8_vec *p = find_key(pKey);
        if (!p)
        {
            data.resize(0);
            return false;
        }

        const uint32_t ofs = vogl_strlen(pKey) + 1;
        const uint8_t *pValue = p->get_ptr() + ofs;
        const uint32_t n = p->size() - ofs;

        data.resize(n);
        if (n)
            memcpy(data.get_ptr(), pValue, n);
        return true;
    }
コード例 #4
0
ファイル: vogl_file_utils.cpp プロジェクト: Nicky-D/vogl
bool file_utils::read_file_to_vec(const char *pPath, uint8_vec &data)
{
    size_t data_size;
    void *p = read_file_to_heap(pPath, data_size);
    if (!p)
        return false;

    if (static_cast<uint>(data_size) != data_size)
        return false;

    if (!data.try_resize(static_cast<uint>(data_size)))
        return false;

    if (!data.grant_ownership(static_cast<uint8 *>(p), static_cast<uint>(data_size), static_cast<uint>(data_size)))
    {
        vogl_free(p);
        return false;
    }

    return true;
}
コード例 #5
0
ファイル: vogl_file_utils.cpp プロジェクト: Nicky-D/vogl
bool file_utils::write_vec_to_file(const char *pPath, const uint8_vec &data)
{
    return write_buf_to_file(pPath, data.get_ptr(), data.size());
}