另分享两个自己封装的模块
时间模块:时间对比,是否在两段时间内,时间差值,时间戳
加密模块:aes des 3des md5 sha bytes到hex hex到bytes
///
/// crc32加密
///
///被加密的字节集
///
public uint GetCRC32(byte[] bytes)
{
try
{
uint crcs = 0;
uint byteslen = (uint)bytes.Length;
uint[] crcTable = new uint[256];
if (byteslen <= 0) { return 0; }
for (int i = 0; i < 256; i++)
{
crcs = (uint)i;
//Debug.WriteLine(crcs + " | " + (crcs & 1) + " | " + i);
for (int d = 0; d < 8; d++)
{
if ((crcs & 1) != 0)
{
crcs = (((crcs >> 1) & 0x7FFFFFFF) ^ 0xEDB88320);
}
else
{
crcs = ((crcs >> 1) & 0x7FFFFFFF);
}
}
crcTable = crcs;
}
uint crc = 0xFFFFFFFF;
for (uint i = 0; i < byteslen; i++)
{
uint wz = ((uint)bytes ^ (crc & 255));
crc = ((crc >> 8) & 0xFFFFFF) ^ crcTable[wz];
}
return ~crc;
}
catch (Exception err)
{
Debug.WriteLine("crc32加密出错 fail;error :" + err.ToString());
return 0;
}
}
下一篇 C#做的两个小游戏