当前位置:   article > 正文

c# cmac算法_将c#改成纯c语言,附c#代码,mac运算用,谢谢了

c#实现cmac算法

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;

}

}

展开

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/51920
推荐阅读
相关标签
  

闽ICP备14008679号