{"id":23157890,"url":"https://github.com/cryptolens/cryptolens-dotnet","last_synced_at":"2025-04-05T23:07:19.835Z","repository":{"id":25825000,"uuid":"29264257","full_name":"Cryptolens/cryptolens-dotnet","owner":"Cryptolens","description":"Client API to access the functionality of Cryptolens Web API","archived":false,"fork":false,"pushed_at":"2025-03-18T15:47:53.000Z","size":9711,"stargazers_count":31,"open_issues_count":27,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-05T23:07:11.558Z","etag":null,"topics":["c-sharp","cryptolens","license-checking","licensing-as-a-service","licensing-library","offline-licensing","software-licensing","unity"],"latest_commit_sha":null,"homepage":"https://help.cryptolens.io","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cryptolens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2015-01-14T20:30:01.000Z","updated_at":"2025-02-05T22:18:44.000Z","dependencies_parsed_at":"2024-03-12T16:30:29.837Z","dependency_job_id":"c388cb3a-a35c-4241-a913-8af3e9992d96","html_url":"https://github.com/Cryptolens/cryptolens-dotnet","commit_stats":null,"previous_names":["serialkeymanager/skgl-extension-for-dot-net","artemlos/skgl-extension-for-dot-net"],"tags_count":75,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Fcryptolens-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Fcryptolens-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Fcryptolens-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cryptolens%2Fcryptolens-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cryptolens","download_url":"https://codeload.github.com/Cryptolens/cryptolens-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411231,"owners_count":20934653,"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":["c-sharp","cryptolens","license-checking","licensing-as-a-service","licensing-library","offline-licensing","software-licensing","unity"],"created_at":"2024-12-17T22:09:20.007Z","updated_at":"2025-04-05T23:07:19.812Z","avatar_url":"https://github.com/Cryptolens.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cryptolens Licensing for .NET\n\nView in other languages (beta): [русский](README.ru.md), [svenska](README.sv.md).\n\nThis API serves as a layer that simplifies communication with Cryptolens Web API 2 and 3 (https://app.cryptolens.io/docs/api).\n\n\u003e You can access the documentation of the library at https://help.cryptolens.io/api/dotnet/.\n\nPlease check out our guide on common errors during integration: https://help.cryptolens.io/faq/index#troubleshooting-api-errors\n\n## Getting started\n\n### Install Nuget package\n\nIn Visual Studio package manager\n```\nPM\u003e Install-Package Cryptolens.Licensing\n```\n\nUsing dotnet CLI\n```\ndotnet add package Cryptolens.Licensing\n```\n\n**If you are targeting Mac, Linux or Unity/Mono, we recommend to use the cross platform version of that package.**\n\nIn Visual Studio package manager\n```\nPM\u003e Install-Package Cryptolens.Licensing.CrossPlatform\n```\n\nUsing dotnet CLI\n```\ndotnet add package Cryptolens.Licensing.CrossPlatform\n```\n\n### Example code\n* [Key verification](https://help.cryptolens.io/examples/key-verification)\n* [Offline verification](https://help.cryptolens.io/examples/offline-verification)\n\n### Recommended articles\n\n* [Unity 3D / Mono](https://help.cryptolens.io/getting-started/unity)\n* [AutoCAD](https://cryptolens.io/2019/01/autocad-plugin-software-licensing/)\n* [Rhinoceros / Grasshoper](https://cryptolens.io/2019/01/protecting-rhinoceros-plugins-with-software-licensing/)\n* [Excel / Office Addins](https://help.cryptolens.io/getting-started/excel)\n\n## Compatibility\n\nTo get access to all of the featues in the library, .NET Framework 4.6 or above has to be used. We have summarized the functionality that is included in each framework. Note, .NET Standard means the library can run on multiple platforms (eg. .NET Core), based on the following [document](https://docs.microsoft.com/en-us/dotnet/standard/net-standard).\n\n* **.NET Framework 4.0** - Verifying metadata signatures is not supported.\n* **.NET Framework 4.6** - All features supported.\n* **.NET Standard 2.0** - Computing machine codes is not supported. You can still use the available hash functions to compute a machine code, assuming you can collect machine specific information.\n* **Unity/Linux/Mac** - You need to use the packages in the \"Without System.Management\" folder on the release page. You can find more info [here](https://help.cryptolens.io/getting-started/unity). \n\nCryptolens.Licensing library does also work on Mono (eg. when running on Linux or Unity), however you need to use a special build that does not include System.Management. You can either install it through [NuGet](https://www.nuget.org/packages/Cryptolens.Licensing.CrossPlatform/), download [pre-compiled binaries](https://github.com/Cryptolens/cryptolens-dotnet/releases) (you need to use the library with the name `Cryptolens.Licensing.CrossPlatform`) or compile it yourself using the instructions below.\n\n## Compiling without System.Management (Linux, Unity, Mono)\nThe easiest way to get the platform independent library is by either installing it through [NuGet](https://www.nuget.org/packages/Cryptolens.Licensing.CrossPlatform/) or downloading [pre-compiled binaries](https://github.com/Cryptolens/cryptolens-dotnet/releases) (the ones that are called `Cryptolens.Licensing.CrossPlatform.dll`). In this section, we describe how to compile it yourself:\n\nTo compile without System.Management, open `Cryptolens.Licensing.csproj` and remove the `\u003cDefineConstants\u003eSYSTEM_MANAGEMENT\u003c/DefineConstants\u003e` below inside the `\u003cPropertyGroup\u003e` tag, i.e.\n\n```\n\u003cPropertyGroup\u003e\n    ...\n\n    \u003cDefineConstants\u003eSYSTEM_MANAGEMENT\u003c/DefineConstants\u003e   \u003c-- remove this\n\u003c/PropertyGroup\u003e\n```\n\n\u003e Make sure there are no other `DefineConstants` definitions later in the file, as these will override the value.\n\n## Other settings\n\n### Issues with Newtonsoft.Json on .NET 4.8\nSome customers have reported an error with the right version of Newtonsoft.Json not being found. It seems to be localized to those that target .NET Framework 4.8, and the following error is shown:\n\n```\nSystem.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.\n```\n\nThe error is thrown when a wrong version of Newtonsoft.Json is installed in the same project as Cryptolens.Licensing library. To fix this, you need to make sure that Newtonsoft.Json is uninstalled completely and then re-install Cryptolens.Licensing.\n\n### Issue with activation even if api.cryptolens.io is accessible in the browser\n\nIf your clients are able to visit `app.cryptolens.io` and `api.cryptolens.io` in Microsoft Edge but unable to activate the application, the issue could be both that they are using a proxy, connect to Active directory or that their IT department has blocked TLS of certain versions.\n\nTo fix these issues, we recommend to:\n\n1. Update to the latest version of the SDK.\n2. If you run a version of .NET Framework prior to .NET Framework 4.7, we recommend to manually specify which TLS should be used. Before any call to the API (for instance, Key.Activate performs an API call), we recommend to add the following line:\n\n```cs\nSystem.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12\n```\n\nIdeally, you should try to pick the highest available TLS version, but it is important to also test that such TLS version is supported in the .NET Framework vesion that you use.\n\nIf possible, the best approach is to run the latest version of .NET Framework. If that is not possible, please use at least .NET Framework 4.7. In other cases, the workaround above can be used (i.e. manually specifying the TLS version).\n\n### 'System.MethodAccessException' when calling Helpers.GetMachineCode\nIn some Windows environments (e.g. when developing Excel addins), it might not be feasible to call Helpers.GetMachineCode on .NET Framework 4.6. The reason for this is the call we make to `System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform`. To fix this, we have added a boolean flag in `Helpers` class. Before calling `Helpers.GetMachineCode` or `Helpers.IsOnRightMachine`, please set `Helpers.WindowsOnly=True`.\n\n```cs\nHelpers.WindowsOnly = true;\nvar machineCode = Helpers.GetMachineCode();\n```\n\nIf the approach above does not work, please try the following call instead:\n\n```cs\nvar machineCode = SKGL.SKM.getMachineCode(SKGL.SKM.getSHA1);\n```\n\n### Turn off KeepAlive\nIn order to perform API calls with KeepAlive disabled, please set `HelperMethods.KeepAlive=False`. If you want to remove all references to code that uses KeepAlive that is true, you can compile the library with the `KeepAliveDisabled` flag, which is added the same way as `SYSTEM_MANAGEMENT` mentioned earlier. If you have multiple flags, they can be separated with a semicolon.\n\n### Proxy settings\nTo change proxy settings, you can use the variable `HelperMethods.proxy`.\n\n## Old examples\n\n### Check Against Time Rollback\nIn order to make sure that the local time (date and time) wasn't changed by the user, the following code can be used.\n```\npublic void HasLocalTimeChanged()\n{\n    bool hasChanged = SKGL.SKM.TimeCheck();\n\n    if(hasChanged)\n    {\n        Debug.WriteLine(\"The local time was changed by the user. Validation fails.\");\n    }\n    else\n    {\n        Debug.WriteLine(\"The local time hasn't been changed. Continue validation.\");\n    }\n}\n```\n\n### Calculating Machine code\nMachine code can be calculated with the function below. Any other hash algorithm will do, as long as it only contains letters and digits only.\n```\npublic void TestingHashes()\n{\n    //eg. \"61843235\" (getEightDigitsLongHash)\n    //eg. \"D38F13CAB8938AC3C393BC111E1A85BB4BA2CCC9\" (getSHA1)\n    string machineID1 = SKGL.SKM.getMachineCode(SKGL.SKM.getEightDigitsLongHash);\n    string machineID2 = SKGL.SKM.getMachineCode(SKGL.SKM.getSHA1);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptolens%2Fcryptolens-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcryptolens%2Fcryptolens-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcryptolens%2Fcryptolens-dotnet/lists"}