本文整理汇总了C++中cryptopp::HexEncoder类的典型用法代码示例。如果您正苦于以下问题:C++ HexEncoder类的具体用法?C++ HexEncoder怎么用?C++ HexEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HexEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asLowerCaseString
std::string transformToSHA256(std::string plainText, bool upperCase)
{
// Crypto++ SHA256 object
CryptoPP::SHA256 hash;
// Use native byte instead of casting chars
byte digest[CryptoPP::SHA256::DIGESTSIZE];
// Do the actual calculation, require a byte value so we need a cast
hash.CalculateDigest(digest, (const byte*)plainText.c_str(), plainText.length());
// Crypto++ HexEncoder object
CryptoPP::HexEncoder encoder;
// Our output
std::string output;
// Drop internal hex encoder and use this, returns uppercase by default
encoder.Attach(new CryptoPP::StringSink(output));
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
// Make sure we want uppercase
if(upperCase)
return output;
// Convert to lowercase if needed
return asLowerCaseString(output);
}
示例2: node
// --------------------------------------------------------------------------
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;
}
}
示例3: crypt
void crypt(string message, int &i, int &output_int_resztaDziel){
CryptoPP::SHA3_512 hash;
byte digest[ CryptoPP::SHA512::DIGESTSIZE ];
hash.CalculateDigest( digest, (byte*)message.c_str(), message.length() );
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();
std::string output_bin;
output_bin = GetBinaryStringFromHexString(output);
std::string output_bin_wynikDziel;
std::string output_bin_resztaDziel;
output_bin_wynikDziel = output_bin.substr(0, output_bin.length()-6); //na sztywno dla m=64
output_bin_resztaDziel = output_bin.substr(output_bin.length()-6, 6);//m = 64
output_int_resztaDziel = GetIntegerFromBinaryString(output_bin_resztaDziel);
char * rho;
const char *coutput_bin = output_bin_wynikDziel.c_str();
rho = strchr(coutput_bin,'1');
i = rho-coutput_bin;
}
示例4: s3fs_keyform
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;
}
示例5: to_string
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));
}
示例6: cache_file
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;
}
示例7: sizeof
std::string MD5encode::encode(std::string const &message)
{
CryptoPP::Weak1::MD5 hash;
byte digest[ CryptoPP::Weak1::MD5::DIGESTSIZE ];
hash.CalculateDigest( digest, (byte*) message.c_str(), message.length() );
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();
std::transform(output.begin(), output.end(), output.begin(), ::tolower);
return (output);
}
示例8: sizeof
//Hash data by MD5 algorhitm
inline std::string MD5(const std::string& data)
{
std::string res;
CryptoPP::MD5 hash;
byte digest[CryptoPP::MD5::DIGESTSIZE];
hash.CalculateDigest(digest, (byte*)data.c_str(), data.size());
CryptoPP::HexEncoder encoder;
encoder.Attach(new CryptoPP::StringSink(res));
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
return res;
}
示例9: hashdomain
string hashdomain(string request)
{
CryptoPP::SHA hashfun;
CryptoPP::HexEncoder encoder;
std::string output;
byte digest[CryptoPP::SHA::DIGESTSIZE];
hashfun.CalculateDigest(digest, (byte*) request.c_str(), request.length());
encoder.Attach(new CryptoPP::StringSink(output));
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
return output;
}
示例10: sizeof
std::string SHA512(std::string data)
{
byte const* pbData = (byte*) data.data();
unsigned int nDataLen = data.size();
byte abDigest[CryptoPP::SHA512::DIGESTSIZE];
CryptoPP::SHA512().CalculateDigest(abDigest, pbData, nDataLen);
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( abDigest, sizeof(abDigest) );
encoder.MessageEnd();
return output;
}
示例11: sizeof
std::string get_sha2_from_string(const std::string& rhs)
{
// byte = typedef for unsigned char
byte hashBytes[CryptoPP::SHA256::DIGESTSIZE] = {0};
CryptoPP::SHA256().CalculateDigest(
hashBytes,
reinterpret_cast<const byte*>(rhs.c_str()),
rhs.length());
CryptoPP::HexEncoder encoder;
std::string hash;
encoder.Attach(new CryptoPP::StringSink(hash));
encoder.Put(hashBytes, sizeof(hashBytes));
encoder.MessageEnd();
return hash;
}
示例12: makeHash
std::string makeHash(const std::string& input)
{
CryptoPP::SHA512 hash;
byte digest[ CryptoPP::SHA512::DIGESTSIZE ];
hash.CalculateDigest( digest, (byte*) input.c_str(), input.length() );
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();
return output;
}
示例13: HashCalculate
/*Calculate SHA1 hash*/
string HashCalculate(string input_string)
{
CryptoPP::SHA1 hash;
byte digest[CryptoPP::SHA1::DIGESTSIZE];
string output;
//calculate hash
hash.CalculateDigest(digest, (const byte *)input_string.c_str(),
input_string.size());
//encode in Hex
CryptoPP::HexEncoder encoder;
CryptoPP::StringSink *SS = new CryptoPP::StringSink(output);
encoder.Attach(SS);
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
//prepend 0x
output = "0x" + output;
return output;
}
示例14: filmonAPIlogin
// Login subscriber
bool filmonAPIlogin(std::string username, std::string password) {
bool res = filmonAPIgetSessionKey();
if (res) {
std::cerr << "FilmonAPI: logging in user" << std::endl;
filmonUsername = username;
filmonpassword = password;
// Password is MD5 hex
CryptoPP::Weak1::MD5 hash;
byte digest[CryptoPP::Weak1::MD5::DIGESTSIZE];
hash.CalculateDigest(digest, (byte*) password.c_str(),
password.length());
CryptoPP::HexEncoder encoder;
std::string md5pwd;
encoder.Attach(new CryptoPP::StringSink(md5pwd));
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
toLowerCase(md5pwd);
std::string params = "login=" + username + "&password=" + md5pwd;
res = filmonRequest("tv/api/login", sessionKeyParam + "&" + params);
if (res) {
Json::Value root;
Json::Reader reader;
reader.parse(&response.memory[0],
&response.memory[(long) response.size - 1], root);
// Favorite channels
channelList.clear();
Json::Value favouriteChannels = root["favorite-channels"];
unsigned int channelCount = favouriteChannels.size();
for (unsigned int channel = 0; channel < channelCount; channel++) {
Json::Value chId = favouriteChannels[channel]["channel"]["id"];
channelList.push_back(chId.asUInt());
std::cerr << "FilmonAPI: added channel " << chId.asUInt()
<< std::endl;
}
clearResponse();
}
}
return res;
}
示例15: OnBnClickedOk
void CLoginDlg::OnBnClickedOk()
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
CComm func;
//환경파일 저장되는지 확인.
CString plainTxt;
m_cID.GetWindowText(m_strID);
m_cPwd.GetWindowText(plainTxt);
#ifdef _HTTPS
CryptoPP::MD5 hash;
byte digest[CryptoPP::MD5::DIGESTSIZE];
std::string message = func.Convert2string(plainTxt);
hash.CalculateDigest(digest, (byte*)message.c_str(), message.length());
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach(new CryptoPP::StringSink(output));
encoder.Put(digest, sizeof(digest));
encoder.MessageEnd();
//std::cout << output << std::endl;
m_strPWD = output.c_str();
m_strPWD.MakeLower();
//OutputDebugString(m_strPWD);
#else
m_strPWD = plainTxt;
#endif
CString strFormData = L"";
strFormData.Format(_T("email=%s&password=%s"), m_strID, m_strPWD);
//로그인
DWORD dwRtn = login(SRV_URL, LGN_API, strFormData);
if (dwRtn == HTTP_STATUS_FORBIDDEN){
MessageBox(L"ID or Password Error!");
m_cID.SetWindowText(L"");
m_cPwd.SetWindowText(L"");
m_cID.SetFocus();
return;
}else if (dwRtn == HTTP_STATUS_DENIED){
//토큰 Expire
AfxMessageBox(L"Token Expire or Not found!");
return;
}
else if (dwRtn != HTTP_STATUS_OK){
MessageBox(L"Login Fail");
m_cID.SetWindowText(L"");
m_cPwd.SetWindowText(L"");
m_cID.SetFocus();
return;
}
//사용자 프로파일 취득.
// 성공일 경우 사용자 프로파일 취득.
dwRtn = userProfile(SRV_URL, PROFILE);
if (dwRtn != HTTP_STATUS_OK){
AfxMessageBox(L"Get User Profile Fail");
return;
}
CDialogEx::OnOK();
}