//***************************************************************
// * 函数名: aaa
// * 功能描述: 产生MAC
// * 入口参数: 1. char *buff 需要进行MAC的字符串
// * 2. int length 字符串的长度
// * 出口参数: 1. char *mac MAC码长度为8
//****************************************************************
void aaa(char *buff,char *mac,int length)
{
int i,j,iTimes,ptr=0;
unsigned char newmac[8]; memset(newmac,0x00,sizeof(newmac)); if (length%8==0)
iTimes=length/8;
else
iTimes=length/8+1; for(i=0;i<iTimes;i++)
{
if( (i<iTimes-1) || ((i==iTimes-1)&&(length/8==0)) )
for(j=0;j<8;j++)
newmac[j]=buff[ptr++]^newmac[j];
else
{
for(j=0;j<8;j++)
if( j<(length%8) )
newmac[j]=buff[ptr++]^newmac[j];
else
newmac[j]=0x00^newmac[j];
}
} //end for
for(j=0;j<8;j++)
{
mac[j*2] =48 + ( (newmac[j]&0xf0) >>4 );
mac[j*2+1]=48 + ( newmac[j]&0x0f );
}
}
// * 函数名: aaa
// * 功能描述: 产生MAC
// * 入口参数: 1. char *buff 需要进行MAC的字符串
// * 2. int length 字符串的长度
// * 出口参数: 1. char *mac MAC码长度为8
//****************************************************************
void aaa(char *buff,char *mac,int length)
{
int i,j,iTimes,ptr=0;
unsigned char newmac[8]; memset(newmac,0x00,sizeof(newmac)); if (length%8==0)
iTimes=length/8;
else
iTimes=length/8+1; for(i=0;i<iTimes;i++)
{
if( (i<iTimes-1) || ((i==iTimes-1)&&(length/8==0)) )
for(j=0;j<8;j++)
newmac[j]=buff[ptr++]^newmac[j];
else
{
for(j=0;j<8;j++)
if( j<(length%8) )
newmac[j]=buff[ptr++]^newmac[j];
else
newmac[j]=0x00^newmac[j];
}
} //end for
for(j=0;j<8;j++)
{
mac[j*2] =48 + ( (newmac[j]&0xf0) >>4 );
mac[j*2+1]=48 + ( newmac[j]&0x0f );
}
}
对C完全没兴趣中...http://lysoft.7u7.net
// * 函数名: aaa
// * 功能描述: 产生MAC
// * 入口参数: 1. char *buff 需要进行MAC的字符串
// * 2. int length 字符串的长度
// * 出口参数: 1. char *mac MAC码长度为8
//****************************************************************
procedure aaa(buff, mac: PChar; length: Integer);
var
i, j, iTimes, ptr: Integer;
ptr: Pointer;
newmac: array [0..7] of Char;
begin
ptr := 0; ZeroMemory(@newmac[0], 0, SizeOf(newmac)); if length mod 8 =0 then
iTimes = length div 8
else
iTimes = length div 8 + 1; for i := 0 to iTimes - 1 do
begin
if (i<iTimes-1) or ((i = iTimes-1) and (length div 8 =0))
for j := 0 to 7 do
begin
newmac[j] = buff[ptr] xor newmac[j];
Inc(ptr);
end
else begin
for j := 0 to 7 do
if j< (length mod 8)
begin
newmac[j]=buff[ptr] xor newmac[j];
Inc(ptr);
end
else
newmac[j] = 0x00 xor newmac[j];
end;
end; //end for
for j := 0 to 7 do
begin
mac[j*2] = 48 + ((newmac[j] and 0xf0) shr 4);
mac[j*2+1]= 48 + (newmac[j] and 0x0f );
end;
end;
newmac[j] := buff[ptr] xor newmac[j];
newmac[j] := 0x00 xor newmac[j];
mac[j*2] := 48 + ((newmac[j] and 0xf0) shr 4);
类型都不支持
帮忙再看看,这样类型我没有接触过
var
i,j,iTimes,ptr: Integer;
newmac: array[0..7] of Byte;
begin ptr := 0;
FillChar(newmac,sizeof(newmac),$00); if (length mod 8=0) then
iTimes := length div 8
else
iTimes := length div 8+1; for i:=0 to iTimes-1 do
begin
if( (i<iTimes-1) or ((i=iTimes-1) and (length/8=0)) ) then
for j:=0 to 7 do
begin
newmac[j] := Byte(buff[ptr]) xor newmac[j];
Inc(ptr);
end
else begin
for j:=0 to 7 do
if( j<(length mod 8) ) then
begin
newmac[j]:=Byte(buff[ptr]) xor newmac[j];
Inc(ptr);
end
else
newmac[j] := $00 xor newmac[j];
end
end; //end for
for j:=0 to 7 do
begin
mac[j*2] :=Char(48 + ( (newmac[j] and $f0) div 16 ));
mac[j*2+1]:=Char(48 + ( newmac[j] and $0f ));
end;
end;