一、Crc计算
RRQM从网上搜集了Crc1-23的计算方法。并封装在了Crc类中。
以最常用的Crc16为例。
byte[] data = new byte[10];
byte[] result = Crc.Crc16(data, 0, data.Length);
二、时间测量器(TimeMeasurer)
功能:封装的Stopwatch,测量运行Action的时间。
TimeSpan timeSpan = TimeMeasurer.Run(() =>
{
Thread.Sleep(1000);
});
三、MD5计算
string str = MD5.GetMD5Hash("RRQM");
bool b = MD5.VerifyMD5Hash("RRQM",str);
四、16进制相关
【将16进制的字符转换为数组】
public static byte[] ByHexStringToBytes(this string hexString, string splite = default)
【将16进制的字符转换为int32】
public static int ByHexStringToInt32(this string hexString)
五、雪花ID生成
雪花ID,会生成long类型的不重复ID。
SnowflakeIDGenerator generator = new SnowflakeIDGenerator(4);
long id=generator.NextID();