static void Main(string[] args) { var sha256 = new System.Security.Cryptography.SHA256Managed(); Console.WriteLine(HashBuilder.Build("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")); Console.ReadKey(); }
public XamlFileDefinition(string file) { Namespaces = new List <NamespaceDeclaration>(); Objects = new List <XamlObjectDefinition>(); FilePath = file; UniqueID = SanitizedFileName + "_" + HashBuilder.Build(FilePath); }
public Dictionary <string, string> GetTelemetryCommonProperties() => new Dictionary <string, string> { { OSVersion, RuntimeEnvironment.OperatingSystemVersion }, { OSPlatform, RuntimeEnvironment.OperatingSystemPlatform.ToString() }, { OutputRedirected, Console.IsOutputRedirected.ToString() }, { RuntimeId, RuntimeEnvironment.GetRuntimeIdentifier() }, { ProductVersion, GetProductVersion() }, { TelemetryProfile, Environment.GetEnvironmentVariable(TelemetryProfileEnvironmentVariable) }, { MachineId, GetMachineId() }, { CurrentPathHash, HashBuilder.Build(_getCurrentDirectory(), SHA256.Create()) }, { KernelVersion, GetKernelVersion() }, };
private string GetMachineId() { try { var macAddr = ( from nic in NetworkInterface.GetAllNetworkInterfaces() where nic.OperationalStatus == OperationalStatus.Up select nic.GetPhysicalAddress().ToString() ).FirstOrDefault(); return(HashBuilder.Build(macAddr, SHA256.Create())); } catch (Exception e) { Debug.Fail($"Failed to get Mac address: {e}"); return(Guid.NewGuid().ToString()); } }
} // レコード // SHA256でハッシュ化 public new string GetHashCode() { return(HashBuilder.Build(id)); }