• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ cryptopp::HexEncoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中cryptopp::HexEncoder的典型用法代码示例。如果您正苦于以下问题:C++ HexEncoder类的具体用法?C++ HexEncoder怎么用?C++ HexEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了HexEncoder类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:AhmedWaly,项目名称:CastOnly,代码行数:29,代码来源:tools.cpp


示例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;
  }
}
开发者ID:fumu-no-kagomeko,项目名称:libkueea-dom,代码行数:35,代码来源:document.cpp


示例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; 
}
开发者ID:158906,项目名称:inz,代码行数:26,代码来源:main.cpp


示例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; 
}
开发者ID:mklim,项目名称:crypto-s3fs-fuse,代码行数:8,代码来源:crypt.cpp


示例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));
}
开发者ID:ComicSansMS,项目名称:blimp,代码行数:10,代码来源:file_hash.cpp


示例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;
}
开发者ID:friederschueler,项目名称:hexahedra,代码行数:13,代码来源:http_cache.cpp


示例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);
}
开发者ID:antiqe,项目名称:RType,代码行数:15,代码来源:MD5encode.cpp


示例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;
        }
开发者ID:str0g,项目名称:PAPServer,代码行数:16,代码来源:myHash.hpp


示例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;
}
开发者ID:Florz,项目名称:smartRNS_UDP_updater,代码行数:15,代码来源:crypto.cpp


示例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;
}
开发者ID:Networc,项目名称:keyshanc,代码行数:15,代码来源:keyshanc.cpp


示例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;
 }
开发者ID:sysbite,项目名称:plaincloud,代码行数:15,代码来源:crypto.cpp


示例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;
}
开发者ID:benjaminhkaiser,项目名称:SKB-Protocol,代码行数:15,代码来源:util.cpp


示例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;
}
开发者ID:apuljain,项目名称:ZKP,代码行数:22,代码来源:CommonFunctions.cpp


示例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;
}
开发者ID:Alpha13s,项目名称:xbmc-pvr-addons,代码行数:41,代码来源:FilmonAPI.cpp


示例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();
}
开发者ID:yuky0312,项目名称:HelloChat,代码行数:70,代码来源:LoginDlg.cpp


示例16: 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);
}
开发者ID:varren,项目名称:Cryptography,代码行数:6,代码来源:Week2ProgrammingAssignment.cpp



注:本文中的cryptopp::HexEncoder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ cryptopp::Integer类代码示例发布时间:2022-05-31
下一篇:
C++ cryptopp::AutoSeededRandomPool类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap