一、Crc计算

RRQM从网上搜集了Crc1-23的计算方法。并封装在了Crc类中。
以最常用的Crc16为例。

  1. byte[] data = new byte[10];
  2. byte[] result = Crc.Crc16(data, 0, data.Length);

二、时间测量器(TimeMeasurer)

功能:封装的Stopwatch,测量运行Action的时间。

  1. TimeSpan timeSpan = TimeMeasurer.Run(() =>
  2. {
  3. Thread.Sleep(1000);
  4. });

三、MD5计算

  1. string str = MD5.GetMD5Hash("RRQM");
  2. bool b = MD5.VerifyMD5Hash("RRQM",str);

四、16进制相关

【将16进制的字符转换为数组】

  1. public static byte[] ByHexStringToBytes(this string hexString, string splite = default)

【将16进制的字符转换为int32】

  1. public static int ByHexStringToInt32(this string hexString)

五、雪花ID生成

雪花ID,会生成long类型的不重复ID。

  1. SnowflakeIDGenerator generator = new SnowflakeIDGenerator(4);
  2. long id=generator.NextID();