From 5e99d68d1e5a75ea08ab8810f7f06e90701b8201 Mon Sep 17 00:00:00 2001 From: nugroho Date: Fri, 16 May 2025 23:49:44 +0700 Subject: [PATCH] global using the SourceGen Regex class --- Commons.cs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Commons.cs b/Commons.cs index ca712e2..e77649d 100644 --- a/Commons.cs +++ b/Commons.cs @@ -7,6 +7,7 @@ global using System.Text.Json.Nodes; global using static perubahan.Commons; global using static perubahan.Logging; global using static perubahan.Middlewares; +global using static perubahan.Regices; global using System.Collections.Concurrent; global using System.Security.Cryptography; using System.Text.Json; @@ -15,7 +16,7 @@ namespace perubahan; internal static class Commons { - internal readonly static string VerNum = "0.1.250509.2301"; + internal readonly static string VerNum = "0.1.250515.1559"; internal static ConcurrentDictionary UserAccounts = []; internal static List Deployments = []; @@ -340,4 +341,30 @@ internal static class DataReaderExtensions } return list; } -} \ No newline at end of file +} +public static class Crc32 +{ + static readonly uint[] Table; + + static Crc32() + { + Table = new uint[256]; + const uint poly = 0xEDB88320; + for (uint i = 0; i < Table.Length; i++) + { + uint crc = i; + for (int j = 0; j < 8; j++) + crc = (crc & 1) != 0 ? (crc >> 1) ^ poly : crc >> 1; + Table[i] = crc; + } + } + + public static uint Compute(byte[] bytes) + { + uint crc = 0xFFFFFFFF; + foreach (byte b in bytes) + crc = (crc >> 8) ^ Table[(crc ^ b) & 0xFF]; + return ~crc; + } +} +