patterns.cpp

来自「C++ patterns设计模式」· C++ 代码 · 共 60 行

CPP
60
字号
#include "stdafx.h"
#include <iostream>
#include "stream/stream.h"
#include "util/util.h"
#include "Patterns/util/md5.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

using namespace std;

void main()
{
	string str = "123456789";
	protocol::BaseStream stream;

	stream.encVmaxString(str, 9);
	stream.enc32(123456);
	string result;
	stream.decVmaxString(result, 9);
	u32 val;
	stream.dec32(val);
	cout << result << endl;
	cout << val << endl;

	char *input = "1234567890~!@#$%^&*()_+|qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?";
	char output[16];
	md5_calc((unsigned char *)output, (unsigned char *)input, strlen(input));
	char output2[16];
	md5digest(output2, input, strlen(input));
	if(memcmp(output, output2, 16) != 0)
	{
		printf("error\n");
	}
	else
	{
		printf("ok");
	}


//	const int PART_SIZE = 9
//	char content[] = "[abc]测试的短消息,this is a test message.";
//
//    char *begin = content;
//    char *prevBegin = content;
//    char *end   = content+strlen(content);
//    char output[PART_SIZE*2+1] = {0};   
//
//    while(begin < end)
//    {
//        size_t howmany = PART_SIZE;
////        stk::takeUCSChar(begin, end, howmany, output);
//        output[begin - prevBegin] = '\0';
//        prevBegin = begin;
//		cout<<howmany<<" "<<output<<endl;
//	}
}

⌨️ 快捷键说明

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