本文整理汇总了C++中cryptopp::HexEncoder::MessageEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ HexEncoder::MessageEnd方法的具体用法?C++ HexEncoder::MessageEnd怎么用?C++ HexEncoder::MessageEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptopp::HexEncoder
的用法示例。
在下文中一共展示了HexEncoder::MessageEnd方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例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: 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;
}
示例11: 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;
}
示例12: 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();
}
示例13: encodeHex
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);
}