{"id":31674901,"url":"https://github.com/ste1io/sk.xbox360.cpukey","last_synced_at":"2026-07-21T01:36:20.155Z","repository":{"id":316849264,"uuid":"1065093883","full_name":"Ste1io/SK.Xbox360.CPUKey","owner":"Ste1io","description":"An immutable .NET data type for Xbox 360 CPUKeys, offering value semantics with optimized parsing, validation, conversion, and utility operations. Suitable for use in collections requiring fast look-up and equality checks.","archived":false,"fork":false,"pushed_at":"2025-10-23T12:40:04.000Z","size":116,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-21T01:36:03.074Z","etag":null,"topics":["cpukey","cryptography","data-type","dotnet","net9","security","xbox","xbox-360","xbox-utility","xbox360","xdk"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ste1io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-27T03:52:19.000Z","updated_at":"2026-05-08T17:35:24.000Z","dependencies_parsed_at":"2025-09-27T05:44:46.374Z","dependency_job_id":"891bc378-f164-47c5-bed8-55424459c11b","html_url":"https://github.com/Ste1io/SK.Xbox360.CPUKey","commit_stats":null,"previous_names":["ste1io/sk.xbox360.cpukey"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ste1io/SK.Xbox360.CPUKey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ste1io%2FSK.Xbox360.CPUKey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ste1io%2FSK.Xbox360.CPUKey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ste1io%2FSK.Xbox360.CPUKey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ste1io%2FSK.Xbox360.CPUKey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ste1io","download_url":"https://codeload.github.com/Ste1io/SK.Xbox360.CPUKey/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ste1io%2FSK.Xbox360.CPUKey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35705774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"ssl_error","status_checked_at":"2026-07-20T02:08:09.736Z","response_time":111,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpukey","cryptography","data-type","dotnet","net9","security","xbox","xbox-360","xbox-utility","xbox360","xdk"],"created_at":"2025-10-08T04:33:23.785Z","updated_at":"2026-07-21T01:36:20.149Z","avatar_url":"https://github.com/Ste1io.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SK.Xbox360.CPUKey\n\n[![.NET 9.0](https://img.shields.io/badge/.NET-9.0-purple.svg)](https://dotnet.microsoft.com/download/dotnet/9.0)\n[![NuGet](https://img.shields.io/nuget/v/SK.Xbox360.CPUKey.svg)](https://www.nuget.org/packages/SK.Xbox360.CPUKey/)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n\nAn immutable .NET data type for Xbox 360 CPUKeys, offering value semantics with optimized parsing, validation, conversion, and utility operations. Designed for high-performance scenarios with zero-allocation span-based APIs and suitable for use in collections requiring fast look-up, equality checks, and sorting.\n\nThe `CPUKey` public interface follows the same familiar dotnet API usage patterns as built-in types like `Guid`, with both strict parsing (throwing exceptions on failure) and safe parsing (returning `bool` and `out` parameter) methods.\n\nA `CPUKey` object is stored as an immutable fixed-size 16-byte array, with no heap allocations after construction, and providing the same value-type semantics as built-in types. `ToString()` implements a lazy string conversion using an optimized custom implementation of `Convert.ToHexString` that avoids redundant exception handling, and minimizes arithmetic and branching using a static lookup table.\n\nAll equality, comparison, and hashing operations are performed directly on the underlying byte array or in `stackalloc` buffers for optimal performance.\n\nSanity checks and integrity validation are performed during initialization to ensure that only cryptographically valid CPUKeys can be constructed, with specialized exception types for different failure modes. Validation includes length checks, non-zero payload, Hamming weight, and ECD (Error Correction and Detection) bits.\n\n## Quick Start\n\n### Basic usage\n\n```cs\nusing SK.Xbox360;\n\n// Initialize from hex strings (case-insensitive), byte arrays, spans, or char spans\nbyte[] arr = [0xC0, 0xDE, 0x8D, 0xAA, 0xE0, 0x54, 0x93, 0xBC, 0xB0, 0xF1, 0x66, 0x4F, 0xB1, 0x75, 0x1F, 0x00];\nstring str = Convert.ToHexString(arr); // \"C0DE8DAAE05493BCB0F1664FB1751F00\"\n\n// Throwing parse (throws exceptions on failure)\nvar parsedKey = CPUKey.Parse(arr);\n\n// Non-throwing parse (returns bool, outputs CPUKey or null/Empty)\nif (CPUKey.TryParse(str, out var cpukey))\n\tConsole.WriteLine($\"Valid CPUKey: {cpukey}\");\n\n// Trivially perform equality/comparison between keys, byte arrays, hex strings, or char spans\nif (cpukey == new CPUKey(\"c0de8daae05493bcb0f1664fb1751f00\"))\n\tConsole.WriteLine($\"CPUKeys match ({parsedKey}).\"); // Outputs: CPUKeys match (C0DE8DAAE05493BCB0F1664FB1751F00).\n\n// Generate a cryptographically-random valid CPUKey\nvar randomKey = CPUKey.CreateRandom();\n\n// Use in collections\nvar keySet = new HashSet\u003cCPUKey\u003e { parsedKey, randomKey };\nvar keyDict = new Dictionary\u003cCPUKey, string\u003e {\n\t[parsedKey] = \"Console #1\",\n\t[randomKey] = \"Console #2\"\n};\n```\n\n### Advanced usage: LINQ queries, database ORMs, network streams\n\n```cs\npublic static class DBExtensions\n{\n\t// ORM helper with LINQ-to-SQL (PetaPoco, Dapper, Entity Framework, etc.)\n\tpublic static Client? GetClient(this IDatabaseService dbService, CPUKey cpukey)\n\t\t=\u003e dbService.DB.SingleOrDefault\u003cClient\u003e(x =\u003e x.CPUKey == cpukey);\n}\n\npublic class Client\n{\n\tpublic int Id { get; set; }\n\tpublic CPUKey CPUKey { get; set; }\n\t//... other properties like Gamertag, IP, etc.\n}\n\ninternal class PacketHandler\n{\n\tpublic bool HandleClientData(EndianReader reader, IDatabaseService db)\n\t{\n\t\tif (!CPUKey.TryParse(reader.ReadBytes(16), out var cpukey) || cpukey is null)\n\t\t{\n\t\t\tConsole.WriteLine(\"Connection contains invalid CPUKey data\");\n\t\t\treturn false;\n\t\t}\n\n\t\tif (db.GetClient(cpukey) is not Client client)\n\t\t{\n\t\t\tConsole.WriteLine($\"Connection from unknown client with CPUKey {cpukey}\");\n\t\t\treturn false;\n\t\t}\n\n\t\t// Handle client connection...\n\t\tConsole.WriteLine($\"Connection from client {client.Id} with CPUKey {client.CPUKey}\");\n\t\treturn true;\n\t}\n}\n```\n\n### Parsing and Validation\n\n```csharp\n// Safe parsing - distinguishes malformed vs invalid\nstring[] testInputs = {\n\t\"C0DE8DAAE05493BCB0F1664FB1751F00\", // Valid\n\t\"STELIOKONTOSCANTC0DECLIFTONMSAID\", // Malformed (non-hex characters)\n\t\"C0DE8DAAE05493BCB0F1664FB1751F01\"  // Invalid (wrong ECD/Hamming weight)\n};\n\nforeach (string input in testInputs)\n{\n\tif (CPUKey.TryParse(input, out CPUKey? cpukey))\n\t\tConsole.WriteLine($\"✓ Valid: {cpukey}\");\n\telse if (cpukey is null)\n\t\tConsole.WriteLine($\"✗ Malformed input: {cpukey}\");\n\telse if (!cpukey.IsValid())\n\t\tConsole.WriteLine($\"✗ Well-formed but invalid: {cpukey}\");\n}\n```\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0 - see the [LICENSE.md](LICENSE.md) file for details.\n\n---\n\n**Made with ❤️ by Stelio Kontos for the Xbox 360 homebrew community**\n\nFor questions, issues, or contributions, please visit the [GitHub repository](https://github.com/Ste1io/SK.Xbox360.CPUKey).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fste1io%2Fsk.xbox360.cpukey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fste1io%2Fsk.xbox360.cpukey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fste1io%2Fsk.xbox360.cpukey/lists"}