{"id":19244327,"url":"https://github.com/nanoframework/system.security.cryptography","last_synced_at":"2026-03-02T12:15:37.248Z","repository":{"id":72129260,"uuid":"345640200","full_name":"nanoframework/System.Security.Cryptography","owner":"nanoframework","description":"📦 .NET nanoFramework System.Security.Cryptography","archived":false,"fork":false,"pushed_at":"2025-04-17T15:27:35.000Z","size":78,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-08-20T06:39:44.163Z","etag":null,"topics":["cryptography","csharp","dotnet","embedded-systems","hacktoberfest","nanoframework"],"latest_commit_sha":null,"homepage":"https://www.nanoframework.net","language":"C#","has_issues":false,"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/nanoframework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"open_collective":"nanoframework","github":"nanoframework"}},"created_at":"2021-03-08T11:57:21.000Z","updated_at":"2025-04-17T15:27:38.000Z","dependencies_parsed_at":"2024-03-16T23:31:25.356Z","dependency_job_id":"36c6a1b2-a691-4244-ab5a-f3865cab9852","html_url":"https://github.com/nanoframework/System.Security.Cryptography","commit_stats":{"total_commits":22,"total_committers":4,"mean_commits":5.5,"dds":"0.31818181818181823","last_synced_commit":"5960148293b12ca9736d9607a8a244b64b2dc428"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/nanoframework/System.Security.Cryptography","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoframework%2FSystem.Security.Cryptography","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoframework%2FSystem.Security.Cryptography/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoframework%2FSystem.Security.Cryptography/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoframework%2FSystem.Security.Cryptography/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nanoframework","download_url":"https://codeload.github.com/nanoframework/System.Security.Cryptography/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nanoframework%2FSystem.Security.Cryptography/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271961717,"owners_count":24850593,"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","status":"online","status_checked_at":"2025-08-24T02:00:11.135Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cryptography","csharp","dotnet","embedded-systems","hacktoberfest","nanoframework"],"created_at":"2024-11-09T17:22:56.837Z","updated_at":"2026-03-02T12:15:37.189Z","avatar_url":"https://github.com/nanoframework.png","language":"C#","funding_links":["https://opencollective.com/nanoframework","https://github.com/sponsors/nanoframework"],"categories":[],"sub_categories":[],"readme":"[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_System.Security.Cryptography\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=nanoframework_System.Security.Cryptography) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=nanoframework_System.Security.Cryptography\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=nanoframework_System.Security.Cryptography) [![NuGet](https://img.shields.io/nuget/dt/nanoFramework.System.Security.Cryptography.svg?label=NuGet\u0026style=flat\u0026logo=nuget)](https://www.nuget.org/packages/nanoFramework.System.Security.Cryptography/) [![#yourfirstpr](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](https://github.com/nanoframework/Home/blob/main/CONTRIBUTING.md) [![Discord](https://img.shields.io/discord/478725473862549535.svg?logo=discord\u0026logoColor=white\u0026label=Discord\u0026color=7289DA)](https://discord.gg/gCyBu8T)\n\n![nanoFramework logo](https://raw.githubusercontent.com/nanoframework/Home/main/resources/logo/nanoFramework-repo-logo.png)\n\n-----\n\n# Welcome to the .NET **nanoFramework** System.Security.Cryptography Library repository\n\nThis repository contains the nanoFramework System.Security.Cryptography class library.\n\n## Build status\n\n| Component | Build Status | NuGet Package |\n|:-|---|---|\n| System.Security.Cryptography | [![Build Status](https://dev.azure.com/nanoframework/System.Security.Cryptography/_apis/build/status%2FSystem.Security.Cryptography?branchName=main)](https://dev.azure.com/nanoframework/System.Security.Cryptography/_build/latest?definitionId=68\u0026branchName=main) | [![NuGet](https://img.shields.io/nuget/v/nanoFramework.System.Security.Cryptography.svg?label=NuGet\u0026style=flat\u0026logo=nuget)](https://www.nuget.org/packages/nanoFramework.System.Security.Cryptography/) |\n\n## System.Security.Cryptography usage\n\nThis library brings to .NET nanoFramework C# applications the equivalent implementations provided by Mbed TLS. The target there the code is going to be deployed has to have a firmware image built with this namespace enabled.\n\n### HMAC SHA256\n\nThis class computes a Hash-based Message Authentication Code (HMAC) by using the SHA256 hash function.\n\nA typical usage for this, in IoT context, is to compute an _hashed_ signature to connect to Azure IoT Hub. Like\n\nProviding one has the _S_hared _A_ccess _K_ey and wants to encode a certain _Uri_ the code snippet that does this is as simple has this:\n\n```csharp\nvar hmacsha256 = new HMACSHA256(Convert.FromBase64String(sharedAccessKey));\n\nbyte[] hash = hmacsha256.ComputeHash(Encoding.UTF8.GetBytes(encodedUri + \"\\n\" + expiry));\n\nstring sig = Convert.ToBase64String(hash);\n```\n\n### AES\n\nAdvanced Encryption Standard (AES)\n\n[AES](https://en.wikipedia.org/wiki/Advanced_Encryption_Standard) is a variant of the Rijndael block cipher with different key and block sizes. For AES, NIST selected three members of the Rijndael family, each with a block size of 128 bits, but three different key lengths: 128, 192 and 256 bits.\n\nThe current version has support for the ECB and CBC modes.\nThe following examples demonstrates how to encrypt and decrypt sample data by using the AES class.\n\nNote that the input data has to be multiple of 16 bits, otherwise an exception will be thrown.\nData shorter than that should be padded with zeros.\n\n#### ECB-AES128\n\n```csharp\n//Sample Usage\nstring clearText = \"Nanoframework\";\nbyte[] clearTextByteArray = Encoding.UTF8.GetBytes(clearText);\n// please note the array size: 16 bytes\nbyte[] clearTextByteArrayWithPadding = new byte[16];\nArray.Copy(clearTextByteArray, 0, clearTextByteArrayWithPadding, 0, clearTextByteArray.Length);\n\n// Create a new instance of the Aes\nAES aes = new AES(CipherMode.ECB);\naes.Key = new byte[16] { 198, 49, 248, 31, 20, 7, 226, 232, 208, 100, 15, 11, 2, 32, 213, 243 };\n\n// Encrypt the bytes to a string.\nvar encryptedData = aes.Encrypt(clearTextByteArrayWithPadding);\nstring encryptedText = Encoding.UTF8.GetString(encryptedData);\nDebug.WriteLine(encryptedText);\n\n// Decrypt the bytes to a string.\nvar decryptedByteArray = aes.Decrypt(encryptedData);\nstring decryptedText = Encoding.UTF8.GetString(decryptedByteArray);\nDebug.WriteLine(decryptedText);\n```\n\n#### CBC-AES128\n\n```csharp\n//Sample Usage\nbyte[] inputBlockCbc1 = new byte[] { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a };\n\n// Create a new instance of the Aes class for CBC\nAes aes = new(CipherMode.CBC);\naes.Key = new byte[] { 198, 49, 248, 31, 20, 7, 226, 232, 208, 100, 15, 11, 2, 32, 213, 243 };;\naes.IV = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };\n\n// Encrypt the bytes\nvar encryptedData = aes.Encrypt(inputBlockCbc1);\nstring encryptedText = Encoding.UTF8.GetString(encryptedData);\nDebug.WriteLine(encryptedText);\n\n// Decrypt the bytes to a string.\nvar decryptedByteArray = aes.Decrypt(encryptedData);\nstring decryptedText = Encoding.UTF8.GetString(decryptedByteArray);\nDebug.WriteLine(decryptedText);\n```\n\n## Feedback and documentation\n\nFor documentation, providing feedback, issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home).\n\nJoin our Discord community [here](https://discord.gg/gCyBu8T).\n\n## Credits\n\nThe list of contributors to this project can be found at [CONTRIBUTORS](https://github.com/nanoframework/Home/blob/main/CONTRIBUTORS.md).\n\n## License\n\nThe **nanoFramework** Class Libraries are licensed under the [MIT license](LICENSE.md).\n\n## Code of Conduct\n\nThis project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community.\nFor more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).\n\n## .NET Foundation\n\nThis project is supported by the [.NET Foundation](https://dotnetfoundation.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoframework%2Fsystem.security.cryptography","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnanoframework%2Fsystem.security.cryptography","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnanoframework%2Fsystem.security.cryptography/lists"}