Esempio n. 1
0
std::string
toString(DataSlice slice)
{
    // Due to a bug, lots of AirBitz encrypted blobs end with a null byte.
    // Get rid of those:
    auto size = slice.size();
    if (0 < size && !slice.data()[size - 1])
        size--;

    return std::string(reinterpret_cast<const char *>(slice.data()), size);
}
Esempio n. 2
0
Status
ScryptSnrp::hash(DataChunk &result, DataSlice data, size_t size) const
{
    DataChunk out(size);

    int rc = crypto_scrypt(data.data(), data.size(),
                           salt.data(), salt.size(), n, r, p, out.data(), size);
    if (rc)
        return ABC_ERROR(ABC_CC_ScryptError, "Error calculating Scrypt hash");

    result = std::move(out);
    return Status();
}
Esempio n. 3
0
/**
 * Casts new-style data to an old-style U08Buf type.
 * DANGER! THIS IS NOT CONST-CORRECT!
 */
inline U08Buf
toU08Buf(DataSlice slice)
{
    return U08Buf(const_cast<uint8_t *>(slice.data()), slice.size());
}