赞
踩
publicclassMAC{publicstaticbyte[]GetMac(byte[]Data){intmac_length=Data.Length;byte[]temp=newbyte[8];intcpoy_length=mac_length>=8?8:(mac_length-8);Array.Copy(Data,0,temp,0...
public class MAC
{
public static byte[] GetMac(byte[] Data)
{
int mac_length = Data.Length;
byte[] temp = new byte[8];
int cpoy_length = mac_length >= 8 ? 8 : (mac_length - 8);
Array.Copy(Data, 0, temp, 0, cpoy_length);
int Group = mac_length % 8 == 0 ? mac_length / 8 : (mac_length / 8 + 1);
for (int i = 1; i < Group; i++)
{
for (int c = 0; c < 8; c++)
{
byte _temp = (mac_length > (i * 8 + c)) ? Data[i * 8 + c] : ((byte)0x00);
temp[c] = (byte)(temp[c] ^ _temp);
}
}
byte[] mac = new byte[8];
AUTODES.generate_mac(temp, mac, 1);
return mac;
}
}
展开
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。