{"id":13693370,"url":"https://github.com/AArnott/PCLCrypto","last_synced_at":"2025-05-02T21:31:58.724Z","repository":{"id":14388597,"uuid":"17098972","full_name":"AArnott/PCLCrypto","owner":"AArnott","description":"Platform crypto for portable libraries","archived":true,"fork":false,"pushed_at":"2024-04-01T14:16:36.000Z","size":5484,"stargazers_count":229,"open_issues_count":5,"forks_count":55,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-05T21:05:03.731Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"ms-pl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AArnott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2014-02-23T01:22:15.000Z","updated_at":"2024-09-27T14:24:27.000Z","dependencies_parsed_at":"2024-06-18T20:12:41.932Z","dependency_job_id":null,"html_url":"https://github.com/AArnott/PCLCrypto","commit_stats":{"total_commits":735,"total_committers":12,"mean_commits":61.25,"dds":0.3129251700680272,"last_synced_commit":"d0530db9d717175df02e1e1f4ae78910af302942"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FPCLCrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FPCLCrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FPCLCrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AArnott%2FPCLCrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AArnott","download_url":"https://codeload.github.com/AArnott/PCLCrypto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252108937,"owners_count":21696163,"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":[],"created_at":"2024-08-02T17:01:08.975Z","updated_at":"2025-05-02T21:31:57.530Z","avatar_url":"https://github.com/AArnott.png","language":"C#","funding_links":["https://github.com/sponsors/AArnott"],"categories":["库和框架","Security","Frameworks and Libs"],"sub_categories":["C#","C-sharp"],"readme":"# PCLCrypto\n\n## ⚠️ Archive notice ⚠️\n\nPCLCrypto hasn't been developed for years.\nIt was written when the .NET runtime that shipped across mobile platforms lacked the crypto that .NET Framework had.\nThat hole has long since been filled.\n.NET has evolved to include scenarios (e.g. trimming) that this library hasn't been tested with nor supports.\nI suggest you switch from PCLCrypto to the standard .NET APIs.\n\n## Summary\n\nPCLCrypto provides cryptographic APIs over algorithms implemented by the platform, including exposing them to portable libraries.\nPCLCrypto does not implement any crypto directly, thus making this library a good choice for applications that require the assurance of high quality crypto implementations that can most reliably be found within the operating system itself or hardware.\n\n[![Build Status](https://dev.azure.com/andrewarnott/OSS/_apis/build/status/PCLCrypto?branchName=main)](https://dev.azure.com/andrewarnott/OSS/_build/latest?definitionId=45\u0026branchName=main)\n[![NuGet package](https://buildstats.info/nuget/PCLCrypto?includePreReleases=true)](https://nuget.org/packages/PCLCrypto)\n[![Join the chat at https://gitter.im/AArnott/PCLCrypto](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/AArnott/PCLCrypto?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n## Features\n\n* Cryptographically strong random number generator\n* Symmetric and asymmetric encryption and signatures\n* Key derivation\n* Native crypto performance for each platform. This provides a 2-100X perf improvement for RSA on Android and iOS.\n* Streaming encryption on UAP, which goes beyond what the WinRT API itself offers (while still relying on the OS for the crypto implementation).\n* Support for multiple key formats (PKCS#1, PKCS#8, CAPI) on all platforms.\n\nThe API is designed to be similar to that found on WinRT or the .NET Framework. However some code changes may be required if migrating to this library from platform-specific crypto.\n\n### Installation\n\nAdd a dependency to this library into your project via the `PCLCrypto` NuGet package:\n\n[![NuGet package](https://buildstats.info/nuget/PCLCrypto?includePreReleases=true)](https://nuget.org/packages/PCLCrypto)\n\nWhen using `packages.config`, you must be sure to install this package into each app project as well as any libraries in order to consume the right PCLCrypto.dll runtime library for the target platform.\nIf you use `PackageReference` (preferred), this happens automatically.\n\nInstalling via NuGet is important because we use facade assemblies and platform-specific assemblies to allow your portable libraries to access crypto that is normally available only to platform-specific libraries using a technique Paul Betts calls [Bait and switch PCLs][BaitAndSwitch]. NuGet handles all the magic for you.\n\n### Documentation\n\nOnline documentation is available on our [project wiki site][Wiki].\n\n### Donations\n\nIf you appreciate this library and/or find it useful, please consider becoming a [GitHub sponsor for its author](https://github.com/sponsors/AArnott)\nor donating bitcoins to `1NC4k82nNev5Cz7ESBfaohbGsC6TKyjKvX` or any other mechanism shown on [their Keybase profile][Keybase].\n\n### FAQ\n\n1. Can I trust the crypto implemented in this library?\n\n   This library does not implement crypto. It merely provides .NET Standard-compatible APIs to invoke crypto, and at runtime the crypto offered by the platform is invoked. So you should be able to trust the crypto available through this library almost as much as you can trust the crypto in the operating system your application is already running on.\n\n### C# 6 Tip\n\nOne of the new features of C# 6 is [using static][StaticUsing], which bring static members of static classes into scope. You can take advantage of this feature with PCLCrypto to simplify your code:\n\nBefore:\n\n```csharp\n...\nusing PCLCrypto;\n\nclass TwitterClient\n{\n    private static string GenerateHash(string input, string key)\n    {\n        var mac = WinRTCrypto.MacAlgorithmProvider.OpenAlgorithm(MacAlgorithm.HmacSha1);\n        var keyMaterial = WinRTCrypto.CryptographicBuffer.ConvertStringToBinary(key, Encoding.UTF8);\n        var cryptoKey = mac.CreateKey(keyMaterial);\n        var hash = WinRTCrypto.CryptographicEngine.Sign(cryptoKey, WinRTCrypto.CryptographicBuffer.ConvertStringToBinary(input, Encoding.UTF8));\n        return WinRTCrypto.CryptographicBuffer.EncodeToBase64String(hash);\n    }\n}\n```\n\nAfter:\n\n```csharp\n...\nusing PCLCrypto;\nusing static PCLCrypto.WinRTCrypto;\n\nclass TwitterClient\n{\n  private static string GenerateHash(string input, string key)\n  {\n      var mac = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithm.HmacSha1);\n      var keyMaterial = CryptographicBuffer.ConvertStringToBinary(key, Encoding.UTF8);\n      var cryptoKey = mac.CreateKey(keyMaterial);\n      var hash = CryptographicEngine.Sign(cryptoKey, CryptographicBuffer.ConvertStringToBinary(input, Encoding.UTF8));\n      return CryptographicBuffer.EncodeToBase64String(hash);\n  }\n}\n```\n\n [BaitAndSwitch]: http://log.paulbetts.org/the-bait-and-switch-pcl-trick/\n [Wiki]: https://github.com/aarnott/pclcrypto/wiki\n [StaticUsing]: http://intellitect.com/static-using-statement-in-c-6-0/\n [Keybase]: https://keybase.io/aarnott\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAArnott%2FPCLCrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAArnott%2FPCLCrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAArnott%2FPCLCrypto/lists"}