Base64编码

编码:

std::string Base64EncryptStr(std::string plaintext)
{
	std::string outstr;

	Base64Encoder encoder;
	encoder.Put((byte*)plaintext.c_str(), plaintext.length());
	encoder.MessageEnd();

	word64 size = encoder.MaxRetrievable();
	if(size)
	{
		outstr.resize(size);		
		encoder.Get((byte*)outstr.data(), outstr.size());
	}

	return outstr;
}

解码:

std::string CCryptoEnvelop::Base64EncryptStr(std::string plaintext)
{
	std::string outstr;

	Base64Encoder encoder;
	encoder.Put((byte*)plaintext.c_str(), plaintext.length());
	encoder.MessageEnd();

	word64 size = encoder.MaxRetrievable();
	if(size)
	{
		outstr.resize(size);		
		encoder.Get((byte*)outstr.data(), outstr.size());
	}

	return outstr;
}
相关文章
相关标签/搜索