{"id":32026091,"url":"https://github.com/ktsu-dev/abstractions","last_synced_at":"2026-02-16T07:17:36.345Z","repository":{"id":309136770,"uuid":"1035269901","full_name":"ktsu-dev/Abstractions","owner":"ktsu-dev","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-14T01:18:10.000Z","size":228,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-14T07:59:44.102Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ktsu-dev.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":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":"COPYRIGHT.md","agents":null,"dco":null,"cla":null}},"created_at":"2025-08-10T03:00:17.000Z","updated_at":"2026-02-14T01:17:17.000Z","dependencies_parsed_at":"2026-02-06T03:01:10.376Z","dependency_job_id":null,"html_url":"https://github.com/ktsu-dev/Abstractions","commit_stats":null,"previous_names":["ktsu-dev/abstractions"],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/ktsu-dev/Abstractions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FAbstractions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FAbstractions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FAbstractions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FAbstractions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ktsu-dev","download_url":"https://codeload.github.com/ktsu-dev/Abstractions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ktsu-dev%2FAbstractions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29502933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T05:57:17.024Z","status":"ssl_error","status_checked_at":"2026-02-16T05:56:49.929Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2025-10-16T13:49:07.475Z","updated_at":"2026-02-16T07:17:36.331Z","avatar_url":"https://github.com/ktsu-dev.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\nstatus: draft\ntitle: ktsu.Abstractions\ndescription: A library providing a comprehensive set of interfaces for compression, encryption, hashing, obfuscation, serialization, and filesystem access with zero-allocation Try* methods and convenient default implementations.\ntags:\n  - abstractions\n  - .net\n  - csharp\n  - provider pattern\n  - dependency injection\n  - serialization\n  - compression\n  - encryption\n  - hashing\n  - obfuscation\n  - zero-allocation\n  - spans\n---\n\n# ktsu.Abstractions\n\nA comprehensive library of interfaces that define a consistent, high-performance API for common cross-cutting concerns:\n\n- **Compression**: `ICompressionProvider` - compress/decompress data with Span\u003cbyte\u003e and Stream support\n- **Encryption**: `IEncryptionProvider` - encrypt/decrypt data with key and IV management\n- **Hashing**: `IHashProvider` - hash data with configurable output length\n- **Obfuscation**: `IObfuscationProvider` - reversible obfuscation/deobfuscation\n- **Serialization**: `ISerializationProvider` - serialize/deserialize objects with TextReader/TextWriter support\n- **Filesystem**: `IFileSystemProvider` - file system operations abstraction\n\nEach interface supports both zero-allocation Try* and Stream based methods and convenient self-allocating methods, with comprehensive async support.\n\n## Target frameworks\n\nThis package multi-targets common frameworks for broad compatibility:\n\n- netstandard2.1\n- net5.0, net6.0, net7.0, net8.0, net9.0\n\nSupported OS: Windows, Linux, macOS.\n\n## Install\n\nVia dotnet CLI:\n\n```bash\ndotnet add package ktsu.Abstractions\n```\n\nVia NuGet Package Manager:\n\n```powershell\nInstall-Package ktsu.Abstractions\n```\n\nVia PackageReference in csproj:\n\n```xml\n\u003cItemGroup\u003e\n    \u003cPackageReference Include=\"ktsu.Abstractions\" Version=\"1.0.0\" /\u003e\n\u003c/ItemGroup\u003e\n```\n\n## Quickstart\n\nUsing the implementations from the `ktsu.Common` package via DI:\n\n```csharp\nusing ktsu.Abstractions;\nusing ktsu.Common;\nusing Microsoft.Extensions.DependencyInjection;\n\nIServiceCollection services = new ServiceCollection();\nservices.AddTransient\u003cICompressionProvider, ktsu.Common.GZipCompressionProvider\u003e();\nservices.AddTransient\u003cIEncryptionProvider, ktsu.Common.AesEncryptionProvider\u003e();\nservices.AddTransient\u003cIHashProvider, ktsu.Common.Sha256HashProvider\u003e();\nservices.AddTransient\u003cIObfuscationProvider, ktsu.Common.Base64ObfuscationProvider\u003e();\nservices.AddTransient\u003cISerializationProvider, ktsu.Common.JsonSerializationProvider\u003e();\nservices.AddTransient\u003cIFileSystemProvider, ktsu.Common.FileSystemProvider\u003e();\n\nusing IServiceProvider provider = services.BuildServiceProvider();\n\nICompressionProvider compressionProvider = provider.GetRequiredService\u003cICompressionProvider\u003e();\nIEncryptionProvider encryptionProvider = provider.GetRequiredService\u003cIEncryptionProvider\u003e();\nIHashProvider hashProvider = provider.GetRequiredService\u003cIHashProvider\u003e();\n\n```\n\n## API Design Pattern\n\nAll interfaces follow a consistent pattern:\n\n1. **Core methods**: Zero-allocation `Try*` methods that work with `Span\u003cbyte\u003e` and `Stream` parameters\n2. **Convenience methods**: Allocating methods that call the Try* methods and handle buffer management\n3. **Async support**: `Task`-based async versions of all operations with `CancellationToken` support\n4. **String overloads**: UTF8-encoded string variants for convenience\n\n### Example Implementation\n\nHere's how to implement a custom MD5 hash provider:\n\n```csharp\nusing System.Security.Cryptography;\nusing ktsu.Abstractions;\n\npublic sealed class MyMD5HashProvider : IHashProvider\n{\n    public int HashLengthBytes =\u003e 16; // MD5 produces 128-bit (16-byte) hashes\n\n    // Zero-allocation implementation\n    public bool TryHash(ReadOnlySpan\u003cbyte\u003e data, Span\u003cbyte\u003e destination)\n    {\n        if (destination.Length \u003c HashLengthBytes)\n        {\n            return false;\n        }\n\n        using var md5 = MD5.Create();\n        byte[] hashBytes = md5.ComputeHash(data.ToArray());\n        hashBytes.AsSpan().CopyTo(destination);\n        \n        return true;\n    }\n\n    // Stream implementation\n    public bool TryHash(Stream data, Span\u003cbyte\u003e destination)\n    {\n        if (destination.Length \u003c HashLengthBytes)\n        {\n            return false;\n        }\n\n        using var md5 = MD5.Create();\n        byte[] hashBytes = md5.ComputeHash(data);\n        hashBytes.AsSpan().CopyTo(destination);\n        \n        return true;\n    }\n    \n    // All other methods (Hash(), HashAsync(), etc.) are provided by default implementations\n}\n```\n\n### Usage Example\n\n```csharp\nusing System.Text;\nusing ktsu.Abstractions;\nusing Microsoft.Extensions.DependencyInjection;\n\nIServiceCollection services = new ServiceCollection();\nservices.AddTransient\u003cIHashProvider, MyMD5HashProvider\u003e();\n\nusing IServiceProvider provider = services.BuildServiceProvider();\nIHashProvider hashProvider = provider.GetRequiredService\u003cIHashProvider\u003e();\n\n// Using the convenience method (allocates and manages buffer)\nbyte[] inputData = Encoding.UTF8.GetBytes(\"Hello, World!\");\nbyte[] hash = hashProvider.Hash(inputData);\n\n// Using string convenience method\nstring textHash = Convert.ToHexString(hashProvider.Hash(\"Hello, World!\"));\n\n// Using the zero-allocation Try method\nSpan\u003cbyte\u003e hashBuffer = stackalloc byte[hashProvider.HashLengthBytes];\nif (hashProvider.TryHash(inputData, hashBuffer))\n{\n    string result = Convert.ToHexString(hashBuffer);\n}\n\n// Async usage\nbyte[] asyncHash = await hashProvider.HashAsync(inputData);\n```\n## Design principles\n\n- **Core methods support zero-allocation and streaming implementations**: The fundamental operations use `Try*` methods that work with caller-provided `Span\u003cbyte\u003e` or `Stream` destinations, returning boolean success indicators.\n- **Default implementations provide convenience**: Interfaces include default implementations for allocating methods (`Hash()`, `Compress()`, etc.) that handle buffer management and forward to the Try* methods.\n- **Comprehensive async support**: All operations have async variants with proper `CancellationToken` support.\n- **String convenience methods**: UTF8-encoded string overloads are provided where appropriate for developer convenience.\n- **Minimal implementation burden**: Implementers only need to provide the core Try* methods; all other functionality is inherited through default interface implementations.\n\n## Security notes\n\n- **Obfuscation** in `IObfuscationProvider` is not cryptography. Use it only for non-security scenarios (e.g., casual hiding). For confidentiality and integrity, use strong, vetted cryptography via `IEncryptionProvider` implementations.\n- Implementations of `IEncryptionProvider` should rely on proven libraries (e.g., .NET BCL crypto, libsodium bindings) and follow best practices (AEAD modes, random IVs/nonces, key management).\n\n## Thread-safety and lifetime\n\n- Provider implementations should be stateless or internally synchronized and safe to register as singletons in DI.\n- If an implementation maintains internal mutable state, document the concurrency model and recommended lifetime.\n\n## Why use these abstractions?\n\n- **Consistency**: A single, predictable surface across implementations\n- **Testability**: Swap implementations and mock easily, especially for filesystem\n- **Separation of concerns**: Keep app code free of vendor-specific details\n\n## Contributing\n\n- Fork the repo and create a feature branch\n- Implement or refine providers/analyzers and add tests\n- Open a pull request\n\n## License\n\nLicensed under the MIT License. See [LICENSE.md](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fabstractions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fktsu-dev%2Fabstractions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fktsu-dev%2Fabstractions/lists"}