• 大小: 5.62MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-15
  • 语言: C/C++
  • 标签: 计网课设  

资源简介

开发平台:VC6.0 MFC 开发语言:C++ 内容:包含源程序和源代码以及相关报告。

资源截图

代码片段和文件信息

// base64.cpp: implementation of the base64 class.
//
//////////////////////////////////////////////////////////////////////

#include “stdafx.h“
#include “SMTP.h“
#include “base64.h“

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////



string base64::Encode(const unsigned char *str int length)
{
//编码表
const char EncodeTable[]=“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;

//返回值
string strEncode;

unsigned char Tmp[3]={0};
int LineLength=0L=length/3;

for(int i=0;i {
        Tmp[0] = *str++;
        Tmp[1] = *str++;
        Tmp[2] = *str++;

        strEncode+= EncodeTable[Tmp[0] >> 2];
        strEncode+= EncodeTable[((Tmp[0] << 4) | (Tmp[1] >> 4)) & 0x3F];
        strEncode+= EncodeTable[((Tmp[1] << 2) | (Tmp[2] >> 6)) & 0x3F];
        strEncode+= EncodeTable[Tmp[2] & 0x3F];
if(LineLength+=4LineLength==76) 
{
strEncode+=“\r\n“;
LineLength=0;
}
}

//对剩余数据进行编码
int Mod=length % 3;
if(Mod==1)
{
        Tmp[0] = *str++;
        strEncode+= EncodeTable[(Tmp[0] & 0xFC) >> 2];// 取前6位,最高位补2个0
        strEncode+= EncodeTable[((Tmp[0] & 0x03) << 4)];//取后2位,补6个0
        strEncode+= “==“;
}
else if(Mod==2)
{
Tmp[0] = *str++;
Tmp[1] = *str++;
strEncode+= EncodeTable[(Tmp[0] & 0xFC) >> 2];
strEncode+= EncodeTable[((Tmp[0] & 0x03) << 4) | ((Tmp[1] & 0xF0) >> 4)];
strEncode+= EncodeTable[((Tmp[1] & 0x0F) << 2)];
strEncode+= “=“;
}

return strEncode;
}

string base64::Decode(const char *str int length int &outlength)
{
//解码表
const char DecodeTable[] =
{
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
62 // ‘+‘
0 0 0
63 // ‘/‘
52 53 54 55 56 57 58 59 60 61 // ‘0‘-‘9‘
0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9 10 11 12
13 14 15 16 17 18 19 20 21 22 23 24 25 // ‘A‘-‘Z‘
0 0 0 0 0 0
26 27 28 29 30 31 32 33 34 35 36 37 38
39 40 41 42 43 44 45 46 47 48 49 50 51 // ‘a‘-‘z‘
};

//返回值
string strDecode;

    int nValue;
    int i= 0;
 
    while (i < length)
    {
        if (*str != ‘\r‘ && *str!=‘\n‘)
        {
            nValue = DecodeTable[*str++] << 18;
            nValue += DecodeTable[*str++] << 12; //拼接两个,有效位为24-19,18-13
strDecode+=(nValue & 0x00FF0000) >> 16;
            outlength++;
 
            if (*str != ‘=‘)
            {
                nValue += DecodeTable[*str++] << 6;
strDecode+=(nValue & 0x0000FF00) >> 8;
                outlength++;
 
                if (*str != ‘=‘)
                {
                    nValue += DecodeTable[*str++];
strDecode+=nValue & 0x000

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     839734  2015-12-05 21:54  邮件客户端.exe

     文件       3277  2015-12-05 17:48  源程序\base64.cpp

     文件        609  2015-12-01 09:27  源程序\base64.h

     文件       3847  2015-12-04 22:12  源程序\BLACK.cpp

     文件       1239  2015-12-04 21:50  源程序\BLACK.h

     文件       2011  2015-12-05 09:07  源程序\CCONTENT.cpp

     文件       1217  2015-12-05 09:06  源程序\CCONTENT.h

     文件      21919  2015-12-05 17:48  源程序\Debug\base64.obj

     文件     283421  2015-12-05 17:48  源程序\Debug\base64.sbr

     文件      38421  2015-12-04 22:14  源程序\Debug\BLACK.obj

     文件     298835  2015-12-04 22:14  源程序\Debug\BLACK.sbr

     文件      26899  2015-12-05 19:44  源程序\Debug\CCONTENT.obj

     文件     286377  2015-12-05 19:44  源程序\Debug\CCONTENT.sbr

     文件      58441  2015-12-05 21:52  源程序\Debug\POP3.obj

     文件     288804  2015-12-05 21:52  源程序\Debug\POP3.sbr

     文件    4228096  2015-12-02 19:35  源程序\Debug\SMTP.bsc

     文件     839734  2015-12-05 21:54  源程序\Debug\SMTP.exe

     文件     684648  2015-12-05 21:54  源程序\Debug\SMTP.ilk

     文件      89852  2015-12-05 21:52  源程序\Debug\SMTP.obj

     文件    6875660  2015-12-04 11:09  源程序\Debug\SMTP.pch

     文件     656384  2015-12-05 21:54  源程序\Debug\SMTP.pdb

     文件     549604  2015-12-05 09:00  源程序\Debug\SMTP.res

     文件     294020  2015-12-05 21:52  源程序\Debug\SMTP.sbr

     文件     132463  2015-12-05 21:54  源程序\Debug\SMTPDlg.obj

     文件     312092  2015-12-05 21:54  源程序\Debug\SMTPDlg.sbr

     文件     105363  2015-12-04 11:09  源程序\Debug\StdAfx.obj

     文件    1371800  2015-12-04 11:09  源程序\Debug\StdAfx.sbr

     文件     328704  2015-12-05 21:54  源程序\Debug\vc60.idb

     文件     479232  2015-12-05 21:54  源程序\Debug\vc60.pdb

     文件      38417  2015-12-04 22:14  源程序\Debug\WHITE.obj

............此处省略33个文件信息

评论

共有 条评论

相关资源