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

📄 base64.cpp

📁 C++下的base64编码
💻 CPP
字号:
// base64.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "base64.h"

#include "base64Util.h"
#include "ICA_Base64Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

void printUsage( char *err )
{
	if( err != NULL )
		printf( "!!!! %s !!!!\n", err );

	printf( "base64 usage:\n" );
	printf( " -encode -in <source_file_name> -out <desc_file_name>\n" );
	printf( " -decode -in <source_file_name> -out <desc_file_name>\n" );
	printf( "\n" );
}

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{
		if( argc <= 1 )
		{
			// 弹出窗口
			CICA_Base64Dlg dlg;
			dlg.DoModal();
		}
		else
		{
			char *pIn			= NULL;
			char *pOut			= NULL;
			bool bDoEncode		= false;
			bool bDoDecode		= false;
			bool bDo64Encode	= false;

			// 控制台处理
			for( int i =1; i < argc; i++ )
			{
				if( stricmp( argv[i], "-encode" ) == 0 )
					bDoEncode = true;
				
				if( stricmp( argv[i], "-decode" ) == 0 )
					bDoDecode = true;

				if( stricmp( argv[i], "-64encode" ) == 0 )
					bDo64Encode = true;

				if( stricmp( argv[i], "-in" ) == 0 )
					pIn = argv[i+1];

				if( stricmp( argv[i], "-out" ) == 0 )
					pOut = argv[i+1];
				
				if( stricmp( argv[i], "-help" ) == 0 ||
					stricmp( argv[i], "-h" ) == 0 ||
					stricmp( argv[i], "/?" ) == 0 )
				{
					printUsage(NULL);
					return nRetCode;
				}
			}

			if( bDoEncode )
				doEncodeFile( pIn, pOut );
			else if( bDoDecode )
				doDecodeFile( pIn, pOut );
			else if( bDo64Encode )
				do64EncodeFile( pIn, pOut );
			else
				printUsage( "Can not find flag! <-encode/-decode/-64encode>" );
		}
	}

	return nRetCode;
}


⌨️ 快捷键说明

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