使用armcc和vc6编程C基本POS设备并且一直试图弄清楚为什么要调用函数“encrypt”(就像我在main方法中所做的那样)我的pos终端重启(重启自己)。有人可以帮忙吗提前谢谢。
#include <stdio.h>
#include <stdlib.h>
#define MAX_CIPHER_SIZE 512
#define MAX_T_SIZE 30
char cipher[MAX_CIPHER_SIZE];
char ca[MAX_CIPHER_SIZE];
int ct[MAX_CIPHER_SIZE];
char Body[MAX_CIPHER_SIZE];
char Token[MAX_T_SIZE+1];
int len;
int n = 253;
int e = 13;
void encrypt(char *plainText, char *cipher, int len)
{
int c;
int k;
int j;
int i;
k=1;
for (i = 0; i < len; i++)
{
c= plainText[i];
for (j = 1; j <= e; j++)
{
k = (k * c) % n;
}
ct[i] = k;
sprintf(ca,"%d", ct[i]);
strcat(cipher, ca);
if(i+1 < len)
{
strcat(cipher,",");
}
}
}
int main(int argc, char *argv[])
{
char *pCode = "6543";
char *pPassword = "2341";
sprintf(Body,"%s#%s#%s","1",pCode, pPassword);
len = strlen(Body);
encrypt(Body, cipher, len);
printf("cypher text = %s\n",cipher);
system("PAUSE");
return 0;
}