⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 base64decoder.cpp

📁 用于base64的解密 将一个包含base64的文件内容取出以后进行解密放到指定的文件里面去
💻 CPP
字号:
#include <iostream>
using std::cout;
using std::cin;
using std::cerr;
using std::endl;
using std::ios;

#include <fstream>
using std::ofstream;
using std::ifstream;

#include <cstdlib>

#include <string.h>
#include "base64decoder.h"

int main()
{
	//array to allocate the space for the file name
	const int size = 100;
	char source[size];
	char target[size];

	cout<<"Enter the name of the file"<<endl;
	cout<<"The first one is the name of the source file"<<endl;
	cin.getline(source,size);
	
	cout<<"and the second one is the name of the target file: "<<endl;
	cin.getline(target,size);

	cout<<source<<endl<<target<<endl;

	ifstream sourceFile(source, ios::in);
	if( !sourceFile )
	{
		cerr<<"source file could not be open!"<<endl;
		exit(1);
	}

	ofstream targetFile(target,ios::out);
	if( !targetFile )
	{
		cerr<<"target file could not be open!"<<endl;
		exit(2);
	}

	sourceFile.seekg(0,ios::end);
    int len = sourceFile.tellg();
	cout<<len<<endl;

	char *copy=new char[len];

	sourceFile.seekg(0);
	sourceFile.read(reinterpret_cast< char * >(copy),len);
	int i;
	for(i = 0; i < len; i++)
	cout<<copy[i];
	cout<<endl;

	//while(sourceFile && !sourceFile.eof())
	char* pszSrc = new char[len];
	int len_src = Base64Decode(pszSrc, copy);
	printf("[源文]:\r\n%s\r\n\r\n", pszSrc);
	cout<<endl<<len_src<<endl;

	targetFile.write(reinterpret_cast< const char *>(pszSrc),len_src);

	for(i = 0; i < len_src; i++)
		cout<<pszSrc[i];


	cout<<endl<<"success!";

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -