9
9903
Unregistered / Unconfirmed
GUEST, unregistred user!
// Returns a char that has been converted to uppercase.
char ucase(char c)
{
if(c>='a' &&
c<='z')
c+='A'-'a';
return c;
}
////////////////////////////////////////////////
ansiuppercase(c:char)
// hex2int
int hex2int(char c)
{
if(c>='A' &&
c<='F')
return(int)(c-'A'+10);
else if(c>='a' &&
c<='f')
return(int)(c-'a'+10);
else if(c>='0' &&
c<='9')
return(int)(c-'0');
return 0;
}
/////////////////////////
function hex2int(c:string):integer;
begin
result := strtoint('$' + c)
end;
// int2hex
char int2hex(int v)
{
char hextable[]="0123456789ABCDEF";
v &= 0xf;
return hextable[v];
}
///////////////////
function int2hex(v:integer):string;
begin
result := inttohex(v,0);
end;
//解密
int DeCode(char *in, char *out)
{
if (in == NULL)
return 0;
int lcnt = strlen(in) >> 1;
if (lcnt == 0)
return 0;
if (in[0] == (char)0)
return 0;
int i = 0;
int icode = 0;
int _edi = 0xf667;
for (i = 0
i < lcnt
i++)
{
out = ((hex2int(ucase(in[i *2])) &0xf) << 4);
out += hex2int(ucase(in[i *2+1])) &0xf;
icode = ((int)out) &0xff;
out ^= ((_edi &0xffff) >> 8);
_edi = (((_edi + icode) *0xce6d) &0xffff) + 0x58bf;
}
out[lcnt] = (char)0;
return 1;
}
//加密
int EnCode(char *in, char *out)
{
int lcnt = strlen(in);
int i = 0;
int icode = 0;
int tcode = 0;
int hbyte = 0;
int lbyte = 0;
int _edi = 0xf667;
for (i = 0
i < lcnt
i++)
{
icode = ((int)in) &0xff;
tcode = icode;
tcode ^= ((_edi &0xffff) >> 8);
hbyte = (tcode &0xf0) >> 4;
lbyte = (tcode &0xf);
out[i *2] = int2hex(hbyte);
out[i *2+1] = int2hex(lbyte);
_edi = (((_edi + tcode) *0xce6d) &0xffff) + 0x58bf;
}
out[i *2] = '/0';
return 1;
}
请问这里面的 EnCode 和 DeCode 怎样翻译???
char ucase(char c)
{
if(c>='a' &&
c<='z')
c+='A'-'a';
return c;
}
////////////////////////////////////////////////
ansiuppercase(c:char)
// hex2int
int hex2int(char c)
{
if(c>='A' &&
c<='F')
return(int)(c-'A'+10);
else if(c>='a' &&
c<='f')
return(int)(c-'a'+10);
else if(c>='0' &&
c<='9')
return(int)(c-'0');
return 0;
}
/////////////////////////
function hex2int(c:string):integer;
begin
result := strtoint('$' + c)
end;
// int2hex
char int2hex(int v)
{
char hextable[]="0123456789ABCDEF";
v &= 0xf;
return hextable[v];
}
///////////////////
function int2hex(v:integer):string;
begin
result := inttohex(v,0);
end;
//解密
int DeCode(char *in, char *out)
{
if (in == NULL)
return 0;
int lcnt = strlen(in) >> 1;
if (lcnt == 0)
return 0;
if (in[0] == (char)0)
return 0;
int i = 0;
int icode = 0;
int _edi = 0xf667;
for (i = 0
i < lcnt
i++)
{
out = ((hex2int(ucase(in[i *2])) &0xf) << 4);
out += hex2int(ucase(in[i *2+1])) &0xf;
icode = ((int)out) &0xff;
out ^= ((_edi &0xffff) >> 8);
_edi = (((_edi + icode) *0xce6d) &0xffff) + 0x58bf;
}
out[lcnt] = (char)0;
return 1;
}
//加密
int EnCode(char *in, char *out)
{
int lcnt = strlen(in);
int i = 0;
int icode = 0;
int tcode = 0;
int hbyte = 0;
int lbyte = 0;
int _edi = 0xf667;
for (i = 0
i < lcnt
i++)
{
icode = ((int)in) &0xff;
tcode = icode;
tcode ^= ((_edi &0xffff) >> 8);
hbyte = (tcode &0xf0) >> 4;
lbyte = (tcode &0xf);
out[i *2] = int2hex(hbyte);
out[i *2+1] = int2hex(lbyte);
_edi = (((_edi + tcode) *0xce6d) &0xffff) + 0x58bf;
}
out[i *2] = '/0';
return 1;
}
请问这里面的 EnCode 和 DeCode 怎样翻译???