Esempio n. 1
2
std::string to_string(Hash const& hash)
{
    CryptoPP::HexEncoder enc;
    enc.Put(reinterpret_cast<byte const*>(hash.digest.data()), hash.digest.size());
    std::array<char, 2*std::tuple_size<decltype(hash.digest)>::value + 1> buffer;
    auto const res = enc.Get(reinterpret_cast<byte*>(buffer.data()), 2*hash.digest.size());
    GHULBUS_ASSERT(res == 2*hash.digest.size());
    buffer.back() = '\0';
    return std::string(begin(buffer), end(buffer));
}
Esempio n. 2
1
int s3fs_keyform(byte* outkey, string inkey)
{
  CryptoPP::HexEncoder encoder;
  encoder.Put((byte*)inkey.c_str(), inkey.length());
  encoder.MessageEnd();
  encoder.Get(outkey, CryptoPP::AES::DEFAULT_KEYLENGTH);
  return 0; 
}
Esempio n. 3
0
// --------------------------------------------------------------------------
document::document () :
 node(std::shared_ptr<document>(this, [](document*){})),
 m_implementation(m_document)
// --------------------------------------------------------------------------
{
  m_html = false;
  m_mode = no_quirks_mode;
  m_content_type = "application/xml";
  m_encoding = "utf-8";
  m_url = "about:blank";

  if (global_object)
  {
    m_origin = global_object->m_document->m_origin;
    m_script_origin = global_object->m_document->m_script_origin;
  }
  else
  {
    // Default is a globally unique identifier.
    // We'll just generate 32 random bytes as the ID.
    
    CryptoPP::AutoSeededRandomPool rng;
    CryptoPP::HexEncoder enc;
    byte bin[32];
    char hex[64];

    rng.GenerateBlock(bin, 32);
    enc.PutMessageEnd(bin, 32);
    enc.Get(reinterpret_cast<byte*>(hex), 64);
    
    m_origin = hex;
    m_script_origin = m_origin;
  }
}
Esempio n. 4
0
fs::path http_cache::cache_file (const std::string& url) const
{
    std::array<uint8_t, 32> digest;
    CryptoPP::SHA().CalculateDigest(digest.data(),
                                    reinterpret_cast<const uint8_t*>(&url[0]),
                                    url.size());
    CryptoPP::HexEncoder hex;
    hex.Put(digest.data(), digest.size());
    std::string hexstr;
    hexstr.resize(64);
    hex.Get(reinterpret_cast<uint8_t*>(&hexstr[0]), 64);
    return dir_ / hexstr;
}
void encodeHex(const  byte * inString1, byte * inString2,const size_t length){
  CryptoPP::HexEncoder hexEncoder;
  hexEncoder.Put(inString1,length);
  hexEncoder.MessageEnd();
  hexEncoder.Get(inString2,length*2);
}