其实加密算法有很多种,前边我讲到过BASE 64、32、16、BCD,说到底都是要跟机器码进行打交道,即二进制码,无论用什么样的加密算法,都要将数据变成二进制数据后再处理,转来转去再转回来,这个模二加算法其实很简单。大体的过程是这样的:
字符—->二进制—->十进制—–>异或(加密)—->二进制—->十进制—->异或(解密)—->字符
我直接上代码吧!
#include "stdafx.h"
#include "string.h"
#pragma warning(disable:4996)
void Ten_Two(int *Ten,int Tlen, unsigned char * data);
void Sencond_Ten(unsigned char *q, int len);
void Str_Two(unsigned char *p,int strLen,unsigned char *q);
void Two_Str(unsigned char *outData,int Tlen,unsigned char *str);
int _tmain(int argc, _TCHAR* argv[])
{
unsigned char inData[]="1a76%s*@Shen雪冰";
int strLen= strlen((char *)inData);
printf("
-----------------------------加密前字符串:
");
printf("%s",inData);
printf("
----------------------------------------------
");
unsigned char *outData=new unsigned char[strLen*8+1];