用OpenSSL 做Base64 编解码(C++)

参考

1)http://www.ioncannon.net/programming/34/howto-base64-encode-with-cc-and-openssl/
2)http://www.ioncannon.net/programming/122/howto-base64-decode-with-cc-and-openssl/
3)http://stackoverflow.com/questions/12109960/openssl-base64-decoding-bio-read-returns-0
4)http://stackoverflow.com/questions/5288076/doing-base64-encoding-and-decoding-in-openssl-c


main.cpp

#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

char * Base64Encode(const char* input, int length, bool with_new_line);
char * Base64Decode(char* input, int length, bool with_new_line);

int main(int argc, char* argv[])
{
	cout << "With new line? y/n ";
	string option;
	cin >> option;
	bool with_new_line = ( ("y" == option || "Y" == option) ? true : false );

	string enc_input = "Henry Alfred Kissinger is a German-born American writer, political scientist, diplomat, and businessman. A recipient of the Nobel Peace Prize, he served as National Security Advisor and later concurrently as Secretary of State in the administrations of Presidents Richard Nixon and Gerald Ford.";

	cout << endl << "To be encoded:" << endl << "~" << enc_input << "~" << endl << endl;

	char * enc_output =

你可能感兴趣的:(用OpenSSL 做Base64 编解码(C++))