G
gaoyongming
Unregistered / Unconfirmed
GUEST, unregistred user!
void cipher_str(char * cipher,int length, unsigned char * passwd)
/*将长度为length*2的字符串转换为16进制串*/
{
int i, k1, k2;
char hex[3], chmap[17]="0123456789abcdef";
memset(passwd,0,length);
for( i = 0;
i < length;
i++ )
{
hex[0] = cipher[i*2];
hex[1] = cipher[i*2+1];
for( k1=0;
k1<16;
k1++ )
if( chmap[k1]==hex[0] )
break;
for( k2=0;
k2<16;
k2++ )
if( chmap[k2]==hex[1] )
break;
*(passwd+i)= (unsigned char)(k1*16+k2);
}
*(passwd+i)='/0';
}
void chg_cip(unsigned char * passwd, int length)
/*口令加密*/
{
int i;
unsigned char temp;
for( i = 0;
i < length;
i++)
{
temp = 0;
passwd = ~passwd;
temp = passwd;
passwd = passwd/16;
temp = temp & 0x0f;
temp = temp*16;
passwd = temp + passwd;
}
}
将上面两个C++函数转换为delphi的过程!谢谢
/*将长度为length*2的字符串转换为16进制串*/
{
int i, k1, k2;
char hex[3], chmap[17]="0123456789abcdef";
memset(passwd,0,length);
for( i = 0;
i < length;
i++ )
{
hex[0] = cipher[i*2];
hex[1] = cipher[i*2+1];
for( k1=0;
k1<16;
k1++ )
if( chmap[k1]==hex[0] )
break;
for( k2=0;
k2<16;
k2++ )
if( chmap[k2]==hex[1] )
break;
*(passwd+i)= (unsigned char)(k1*16+k2);
}
*(passwd+i)='/0';
}
void chg_cip(unsigned char * passwd, int length)
/*口令加密*/
{
int i;
unsigned char temp;
for( i = 0;
i < length;
i++)
{
temp = 0;
passwd = ~passwd;
temp = passwd;
passwd = passwd/16;
temp = temp & 0x0f;
temp = temp*16;
passwd = temp + passwd;
}
}
将上面两个C++函数转换为delphi的过程!谢谢