{"id":25473732,"url":"https://github.com/rubenwihler/hybridencryption","last_synced_at":"2025-11-05T09:30:30.883Z","repository":{"id":211085640,"uuid":"728139464","full_name":"RubenWihler/HybridEncryption","owner":"RubenWihler","description":"The EncryptionManager class provides a set of methods for performing combined RSA and AES encryption and decryption in C#. This class enables the generation of RSA key pairs, encryption of text using a combination of RSA and AES, and subsequent decryption of the encrypted text.","archived":false,"fork":false,"pushed_at":"2023-12-06T10:17:25.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-12-06T12:31:18.319Z","etag":null,"topics":["aes-rsa","csharp-utils","encryption-utility","hybrid-encryption"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RubenWihler.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-12-06T10:08:32.000Z","updated_at":"2023-12-06T12:31:20.139Z","dependencies_parsed_at":"2023-12-06T12:31:19.991Z","dependency_job_id":"63b1541a-2895-4ff2-8208-15a64a634c89","html_url":"https://github.com/RubenWihler/HybridEncryption","commit_stats":null,"previous_names":["rubenwihler/hybridencryption"],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubenWihler%2FHybridEncryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubenWihler%2FHybridEncryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubenWihler%2FHybridEncryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubenWihler%2FHybridEncryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubenWihler","download_url":"https://codeload.github.com/RubenWihler/HybridEncryption/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239453836,"owners_count":19641428,"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":["aes-rsa","csharp-utils","encryption-utility","hybrid-encryption"],"created_at":"2025-02-18T10:37:31.410Z","updated_at":"2025-02-18T10:37:31.920Z","avatar_url":"https://github.com/RubenWihler.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HybridEncryption class Documentation\n\n## Overview\n\nThe `HybridEncryption` class provides a set of methods for performing combined RSA and AES encryption and decryption in C#. This class enables the generation of RSA key pairs, encryption of text using a combination of RSA and AES, and subsequent decryption of the encrypted text.\n\n## Table of Contents\n\n1. [RSA Key Generation](#rsa-key-generation)\n2. [Text Encryption](#text-encryption)\n3. [Text Decryption](#text-decryption)\n4. [Private Methods](#private-methods)\n\n## RSA Key Generation \u003ca name=\"rsa-key-generation\"\u003e\u003c/a\u003e\n\n```csharp\npublic static (string publicKey, string privateKey) GenerateRSAKeys()\n```\n\n### `GenerateRSAKeys` Method\n\n#### Description\n\nGenerates a pair of private and public RSA keys and returns them as XML strings.\n\n#### Signature\n\n```csharp\npublic static (string publicKey, string privateKey) GenerateRSAKeys()\n```\n\n#### Parameters\n\nNone\n\n#### Returns\n\n- `publicKey`: The public RSA key in XML format.\n- `privateKey`: The private RSA key in XML format.\n\n#### Example\n\n```csharp\nvar keys = HybridEncryption.GenerateRSAKeys();\nvar publicKey = keys.publicKey;\nvar privateKey = keys.privateKey;\n```\n\n------------------------------------------------------------------------------------------------------------------------\n\n## Text Encryption \u003ca name=\"text-encryption\"\u003e\u003c/a\u003e\n\n```csharp\npublic static (string text, string aesKey, string aesIV) Encrypt(string text, string publicKey)\n```\n\n### `Encrypt` Method\n\n#### Description\n\nEncrypts a given text using a combination of RSA and AES. It generates AES key and IV, encrypts them with the provided RSA public key, and then encrypts the text using AES.\n\n#### Signature\n\n```csharp\npublic static (string text, string aesKey, string aesIV) Encrypt(string text, string publicKey)\n```\n\n#### Parameters\n\n- `text`: The text to be encrypted.\n- `publicKey`: The target RSA public key in XML format.\n\n#### Returns\n\n- `text`: The encrypted text in Base64 format.\n- `aesKey`: The encrypted AES key in Base64 format.\n- `aesIV`: The encrypted AES initialization vector (IV) in Base```\n\n#### Example\n\n```csharp\nvar encryptionResult = HybridEncryption.Encrypt(\"Hello, World!\", publicKey);\nvar encryptedText = encryptionResult.text;\nvar encryptedAESKey = encryptionResult.aesKey;\nvar encryptedAESIV = encryptionResult.aesIV;\n```\n\n------------------------------------------------------------------------------------------------------------------------\n\n## Text Decryption \u003ca name=\"text-decryption\"\u003e\u003c/a\u003e\n\n```csharp\npublic static string Decrypt(string encryptedText, string aesKey, string aesIV, string privateKey)\n```\n\n### `Decrypt` Method\n\n#### Description\n\nDecrypts the provided encrypted text. It decrypts the AES key and IV with the private RSA key and then uses them to decrypt the text.\n\n#### Signature\n\n```csharp\npublic static string Decrypt(string encryptedText, string aesKey, string aesIV, string privateKey)\n```\n\n#### Parameters\n\n- `encryptedText`: The encrypted text in Base64 format.\n- `aesKey`: The encrypted AES key in Base64 format.\n- `aesIV`: The encrypted AES initialization vector (IV) in Base64 format.\n- `privateKey`: The private RSA key in XML format.\n\n#### Returns\n\n- The decrypted text.\n\n#### Example\n\n```csharp\nvar decryptedText = HybridEncryption.Decrypt(encryptedText, encryptedAESKey, encryptedAESIV, privateKey);\n```\n\n------------------------------------------------------------------------------------------------------------------------\n\n## Private Methods \u003ca name=\"private-methods\"\u003e\u003c/a\u003e\n\n```csharp\nprivate static byte[] RsaEncrypt(string data, string publicKey)\n```\n\n### `RsaEncrypt` Method\n\n#### Description\n\nEncrypts data using RSA encryption with the provided RSA public key.\n\n#### Signature\n\n```csharp\nprivate static byte[] RsaEncrypt(string data, string publicKey)\n```\n\n#### Parameters\n\n- `data`: The data to be encrypted in Base64 format.\n- `publicKey`: The RSA public key in XML format.\n\n#### Returns\n\n- The encrypted data.\n\n------------------------------------------------------------------------------------------------------------------------\n\n```csharp\nprivate static byte[] RsaDecrypt(string data, string privateKey)\n```\n\n### `RsaDecrypt` Method\n\n#### Description\n\nDecrypts data using RSA decryption with the provided RSA private key.\n\n#### Signature\n\n```csharp\nprivate static byte[] RsaDecrypt(string data, string privateKey)\n```\n\n#### Parameters\n\n- `data`: The data to be decrypted in Base64 format.\n- `privateKey`: The RSA private key in XML format.\n\n#### Returns\n\n- The decrypted data.\n\n------------------------------------------------------------------------------------------------------------------------\n\n```csharp\nprivate static byte[] AesEncrypt(string data, byte[] key, byte[] IV)\n```\n\n### `AesEncrypt` Method\n\n#### Description\n\nEncrypts data using AES encryption with the provided AES key and initialization vector (IV).\n\n#### Signature\n\n```csharp\nprivate static byte[] AesEncrypt(string data, byte[] key, byte[] IV)\n```\n\n#### Parameters\n\n- `data`: The data to be encrypted.\n- `key`: The AES key.\n- `IV`: The AES initialization vector (IV).\n\n#### Returns\n\n- The encrypted data.\n\n------------------------------------------------------------------------------------------------------------------------\n\n```csharp\nprivate static string AesDecrypt(byte[] cipherText, byte[] key, byte[] IV)\n```\n\n### `AesDecrypt` Method\n\n#### Description\n\nDecrypts data using AES decryption with the provided AES key and initialization vector (IV).\n\n#### Signature\n\n```csharp\nprivate static string AesDecrypt(byte[] cipherText, byte[] key, byte[] IV)\n```\n\n#### Parameters\n\n- `cipherText`: The encrypted data.\n- `key`: The AES key.\n- `IV`: The AES initialization vector (IV).\n\n#### Returns\n\n- The decrypted data.\n\n------------------------------------------------------------------------------------------------------------------------\n\n```csharp\nprivate static (byte[] key, byte[] IV) GenerateAESKey()\n```\n\n### `GenerateAESKey` Method\n\n#### Description\n\nGenerates a pair of AES key and initialization vector (IV).\n\n#### Signature\n\n```csharp\nprivate static (byte[] key, byte[] IV) GenerateAESKey()\n```\n\n#### Parameters\n\nNone\n\n#### Returns\n\n- `key`: The generated AES key.\n- `IV`: The generated AES initialization vector (IV).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenwihler%2Fhybridencryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenwihler%2Fhybridencryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenwihler%2Fhybridencryption/lists"}