md5tmp.cpp

来自「MD5的C++源码」· C++ 代码 · 共 60 行

CPP
60
字号
#include "md5.h"
#include <iostream.h>
#include <String>

using namespace std;

LPCSTR TargetFile(char *filename=NULL);
//计算文件的MD5值
void TargetStr(LPCSTR str);
//计算字符串的MD5值
LPCSTR GetDigestKey();
//取MD5运算后的结果


int main(int argc,char ** argv)
{
    cout<<"MD5 加密系统:"<<endl<<endl;
    string option;
    int select;
 while(1)
 {
     cout<<"Please input your Option :"<<endl
      <<"**********************************"<<endl
   <<"*                                *"<<endl
   <<"*   1 .文件 2 .字符串  Q .退出   *"<<endl
   <<"*                                *"<<endl
   <<"**********************************"<<endl;
  cin>>option;
  if("Q" == option | "q" == option)
   break;
  select = atoi(option.c_str());
  switch(select)
  {
   case 1:
    {
     cout<<"输入要加密的文件名完整路径:"<<endl;
     CMd5 md5;
     string sourse;
     cin>>sourse;                   
                    md5.TargetFile((char*)sourse.c_str());
                    cout<<md5.GetDigestKey()<<endl;
                    break;
    }
   case 2:
    {
                 cout<<"输入要加密的字符串:"<<endl;
     CMd5 md5;
     string sourse;
     cin>>sourse;
     md5.TargetStr(sourse.c_str());
     cout<<md5.GetDigestKey()<<endl;
     break;
                }
   default:
    cout<<"你输入的序号不正确(1 or 2 or Q):"<<endl;
  }
 }
}

⌨️ 快捷键说明

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