{"id":14968309,"url":"https://github.com/junian/standard.licensing","last_synced_at":"2025-05-15T09:08:30.034Z","repository":{"id":37336458,"uuid":"121832084","full_name":"junian/Standard.Licensing","owner":"junian","description":"Easy-to-use licensing library for .NET Framework, Mono, .NET Core, and MAUI / Xamarin products","archived":false,"fork":false,"pushed_at":"2024-11-14T08:46:36.000Z","size":12348,"stargazers_count":601,"open_issues_count":23,"forks_count":140,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-05-15T09:08:19.684Z","etag":null,"topics":["dotnet","licensing","mono","netcore","netframework","netstandard","xamarin"],"latest_commit_sha":null,"homepage":"https://junian.dev/Standard.Licensing/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junian.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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},"funding":{"github":null,"patreon":"junian","open_collective":null,"ko_fi":"junian","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"junian","custom":["paypal.me/junian"]}},"created_at":"2018-02-17T06:10:13.000Z","updated_at":"2025-05-07T18:43:49.000Z","dependencies_parsed_at":"2024-11-14T09:26:56.147Z","dependency_job_id":"38bb09a5-cdd2-4ac9-9f49-e877ff359b48","html_url":"https://github.com/junian/Standard.Licensing","commit_stats":{"total_commits":293,"total_committers":7,"mean_commits":"41.857142857142854","dds":0.4573378839590444,"last_synced_commit":"752186edb3668fa751030df1016a88ba14972627"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junian%2FStandard.Licensing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junian%2FStandard.Licensing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junian%2FStandard.Licensing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junian%2FStandard.Licensing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junian","download_url":"https://codeload.github.com/junian/Standard.Licensing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310520,"owners_count":22049470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["dotnet","licensing","mono","netcore","netframework","netstandard","xamarin"],"created_at":"2024-09-24T13:39:41.597Z","updated_at":"2025-05-15T09:08:25.016Z","avatar_url":"https://github.com/junian.png","language":"C#","funding_links":["https://patreon.com/junian","https://ko-fi.com/junian","https://buymeacoffee.com/junian","paypal.me/junian"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/junian/Standard.Licensing/master/assets/img/standard-licensing-logo.png\" alt=\"Standard.Licensing Logo\"\u003e\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eStandard.Licensing\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003eEasy-to-use licensing library for .NET and .NET Framework products.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/junian/Standard.Licensing/\"\u003e\u003cimg src=\"https://img.shields.io/badge/GitHub-%23121011.svg?logo=github\u0026logoColor=white\u0026style=for-the-badge\" alt=\"Standard.Licensing on GitHub\" title=\"Standard.Licensing on GitHub\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.nuget.org/packages/Standard.Licensing/\"\u003e\u003cimg src=\"https://img.shields.io/nuget/v/Standard.Licensing.svg?style=for-the-badge\" alt=\"Standard.Licensing latest version on NuGet\" title=\"Standard.Licensing latest version on NuGet\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.nuget.org/packages/Standard.Licensing/\"\u003e\u003cimg src=\"https://img.shields.io/nuget/dt/Standard.Licensing.svg?style=for-the-badge\" alt=\"Standard.Licensing total downloads on NuGet\" title=\"Standard.Licensing total downloads on NuGet\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n----\n\n\u003c!--\n![Standard.Licensing Logo](https://raw.githubusercontent.com/junian/Standard.Licensing/master/assets/img/standard-licensing-logo.png)\n\n# Standard.Licensing\n\nEasy-to-use licensing library for .NET and .NET Framework products.\n--\u003e\n\n## Installation\n\nGet [Standard.Licensing](https://www.nuget.org/packages/Standard.Licensing/) from NuGet.\n\n```shell\ndotnet add package Standard.Licensing\n```\n\n## Usage\n\n### Create a private and public key for your product\n\nStandard.Licensing uses the Elliptic Curve Digital Signature Algorithm (ECDSA) to ensure the license cannot be altered after creation.\n\nFirst you need to create a new public/private key pair for your product:\n\n```csharp\nvar keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create(); \nvar keyPair = keyGenerator.GenerateKeyPair(); \nvar privateKey = keyPair.ToEncryptedPrivateKeyString(passPhrase);  \nvar publicKey = keyPair.ToPublicKeyString();\n```\n\nStore the private key securely and distribute the public key with your product.\nNormally you create one key pair for each product, otherwise it is possible to use a license with all products using the same key pair.\nIf you want your customer to buy a new license on each major release you can create a key pair for each release and product.\n\n### Create the license generator\n\nNow we need something to generate licenses. This could be easily done with the `LicenseFactory`:\n\n```csharp\nvar license = License.New()  \n    .WithUniqueIdentifier(Guid.NewGuid())  \n    .As(LicenseType.Trial)  \n    .ExpiresAt(DateTime.Now.AddDays(30))  \n    .WithMaximumUtilization(5)  \n    .WithProductFeatures(new Dictionary\u003cstring, string\u003e  \n        {  \n            {\"Sales Module\", \"yes\"},  \n            {\"Purchase Module\", \"yes\"},  \n            {\"Maximum Transactions\", \"10000\"}  \n        })  \n    .LicensedTo(\"John Doe\", \"john.doe@example.com\")  \n    .CreateAndSignWithPrivateKey(privateKey, passPhrase);\n```\n\nNow you can take the license and save it to a file:\n\n```csharp\nFile.WriteAllText(\"License.lic\", license.ToString(), Encoding.UTF8);\n```\n\nor\n\n```csharp\nlicense.Save(xmlWriter);\n```\n\n### Validate the license in your application ###\n\nThe easiest way to assert the license is in the entry point of your application.\n\nFirst load the license from a file or resource:\n\n```csharp\nvar license = License.Load(...);\n```\n\nThen you can assert the license:\n\n```csharp\nusing Standard.Licensing.Validation;\n\nvar validationFailures = license.Validate()  \n                                .ExpirationDate(systemDateTime: DateTime.Now)  \n                                .When(lic =\u003e lic.Type == LicenseType.Trial)  \n                                .And()  \n                                .Signature(publicKey)  \n                                .AssertValidLicense();\n```\n\nStandard.Licensing will not throw any Exception and just return an enumeration of validation failures.\n\nNow you can iterate over possible validation failures:\n\n```csharp\nforeach (var failure in validationFailures)\n     Console.WriteLine(failure.GetType().Name + \": \" + failure.Message + \" - \" + failure.HowToResolve);\n```\n\nOr simply check if there is any failure:\n\n```csharp\nif (validationFailures.Any())\n   // ...\n```\n\nMake sure to call `validationFailures.ToList()` or `validationFailures.ToArray()` before using the result multiple times.\n\n## Third Party Projects\n\n- [PatrickRainer/LicenseManager](https://github.com/PatrickRainer/LicenseManager) - A WPF license manager for developers to generate and validate licenses.\n- [skst/LicenseManager](https://github.com/skst/LicenseManager) - GUI front-end for Standard.Licensing project.\n\n## Credits\n\nThis is project is derived from [Portable.Licensing](https://github.com/dnauck/Portable.Licensing/) library.\nThe purpose of this fork is to add support for more .NET platforms, especially .NET Standard and .NET Core.\n\n- [dnauck/Portable.Licensing](https://github.com/dnauck/Portable.Licensing/) for the original work.\n\n## License\n\nThis project is licensed under [MIT License](https://github.com/junian/Standard.Licensing/blob/master/LICENSE).\n\n---\n\nMade with ☕ by [Junian.dev](https://www.junian.dev).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunian%2Fstandard.licensing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunian%2Fstandard.licensing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunian%2Fstandard.licensing/lists"}