public virtual UInt32 GenerateModID() { ICRC algorithm = CRCFactory.Instance.Create(crcSetting); string crc_input = ModIdString; return(BitConverter.ToUInt32(algorithm.ComputeHash(Encoding.UTF8.GetBytes(crc_input).Select(dr => (byte)dr).ToArray()).Hash, 0) | 0x80000000); }
public ModeResult Run(string[] args) { if (args.Length < 2) { Console.Out.WriteLine("Missing required arg: \"output\""); return(ModeResult.Fail); } string dataDirectory; if (args.Length >= 2) { dataDirectory = args[1]; } else { dataDirectory = StructuredDataInfo.GetDefaultDirectory(); } _info = new StructuredDataInfo(dataDirectory); ICRC crc32 = CRCFactory.Instance.Create(CRCConfig.CRC32); foreach (KeyValuePair <uint, string> instance in _info.KnownInstances) { //if (instance.Value.StartsWith("STUStatescript")) { if (instance.Value.StartsWith("M")) { continue; } string mirrorType = instance.Value.Replace("STU", "M"); if (!mirrorType.StartsWith("M")) { continue; } uint hash = BitConverter.ToUInt32(crc32.ComputeHash(Encoding.ASCII.GetBytes(mirrorType.ToLowerInvariant())).Hash, 0); if (_info.Instances.ContainsKey(hash)) { Console.Out.WriteLine($"{hash:X8}, {mirrorType}"); } //} } return(ModeResult.Success); }
public byte[] DataHashFunctionCrc32() { var hash = crc32Provider.ComputeHash(data); return(hash.Hash); }
public static string CalcCRC32(string password) { return(BitConverter.ToInt32(crc32.ComputeHash(Encoding.UTF8.GetBytes(password)).Hash, 0).ToString()); }
/// <summary> /// Uses CRC-16/X-25 algorithm, also FCS field is little-endian /// </summary> /// <param name="data">Packet contents without flags and the FCS field itself</param> /// <returns>Two bytes (little-endian CRC-16)</returns> public static byte[] ComputeFCS(byte[] data) { return(CrcFactory.ComputeHash(data).Hash); }