Now, I want to use Class Integer, I generate a 512bit integer and want to transfer it
to string or some other form that can be easy to transfered; I use encode, decode
functions to implement it; but it seems doesn't work correctly;
below is my code:
void main()
{
Integer *a;
char * seed;
seed =NULL;
byte b;
std::string timeSeed;
// generate a random 512bit Integer
if (!seed)
{
timeSeed = IntToString(time(NULL));
seed = (char*)malloc(timeSeed.length());
strcpy(seed , timeSeed.c_str());
}
GlobalRNG().Put((const byte *)seed, strlen(seed));
a = new Integer();
a->Randomize(GlobalRNG(),512);
// print the Integer value
std::string str;
char s[64];
int len = a->ByteCount();
for(int i=0; i<len;i++)
{
b = a->GetByte(i);
sprintf(s,"%x",b);
printf("%x",b);
str += s;
}
printf("\n");
byte *tmp;
tmp = (byte*) malloc(len);
a->Encode(tmp,len); //encode a to byte array tmp
for(i=0; i<len;i++) //print tmp
{
printf("%x",*tmp);
tmp++;
}
printf("\n");
Integer *x;
x = new Integer();
x->Decode(tmp,len);
int r=x->Compare(*a);
printf("compare = %i",r); //here r is 1
[EMAIL PROTECTED]
2003-09-20