{"id":25638520,"url":"https://github.com/marfusios/mkencryptor.core","last_synced_at":"2025-10-25T14:15:58.794Z","repository":{"id":66301075,"uuid":"57965786","full_name":"Marfusios/MKEncryptor.Core","owner":"Marfusios","description":"Encryption portable library/wrapper for C#","archived":false,"fork":false,"pushed_at":"2016-05-03T12:02:33.000Z","size":3592,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-23T02:33:22.446Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Marfusios.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-03T11:57:22.000Z","updated_at":"2018-10-26T20:23:09.000Z","dependencies_parsed_at":"2023-02-22T05:00:13.171Z","dependency_job_id":null,"html_url":"https://github.com/Marfusios/MKEncryptor.Core","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Marfusios/MKEncryptor.Core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marfusios%2FMKEncryptor.Core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marfusios%2FMKEncryptor.Core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marfusios%2FMKEncryptor.Core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marfusios%2FMKEncryptor.Core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marfusios","download_url":"https://codeload.github.com/Marfusios/MKEncryptor.Core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marfusios%2FMKEncryptor.Core/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266019657,"owners_count":23864916,"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":"2025-02-23T02:31:43.131Z","updated_at":"2025-10-25T14:15:53.761Z","avatar_url":"https://github.com/Marfusios.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MKEncryptor.Core\n\nEncryption portable library/wrapper for C#. It is used in commercial product [MKEncryptor](https://www.microsoft.com/en-us/store/apps/mk-encryptor/9nblggh682ch). \n\n* How encryption works\n    1. Initial vector (IV) and salt (128b) is randomly generated (by SecureRandom)\n    2. Password is generated by Pkcs5S2ParametersGenerator via 13333 iteration count (it uses users password and salt)\n    3. Password generating produces derived mac parameters (HMAC)\n    4. Check if HMAC is valid\n    5. Data are encrypted by selected provider and cipher\n    \n* Currently supported providers and ciphers:\n    * [Bouncy Castle](https://www.bouncycastle.org/) - open source cryptography library\n        * AES\n        * AES Fast\n        * Blowfish\n        * Camellia\n        * Des\n        * Gost28147\n        * Serpent\n        * Twofish\n        \n* Sample:\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var encryptor = new MKEncryptor();\n        var camelliaCipher = encryptor.FindCipherBy(\"camellia\", \"bouncy_castle\");\n        \n        var password = \"my password\";\n        var plainText = \"my secret text\";\n        \n        var encrypted = encryptor.Encrypt(plainText, password, cipher, MKKeySize.Key256);\n        var decrypted = encryptor.Decrypt(encrypted, password, cipher, MKKeySize.Key256);\n        \n        // decrypted == plainText\n    }\n}\n```\n\n* Minimal targets\n    * .NET Framework 4.5\n    * .NET Core 1.0\n    * Windows 8\n    * Windows Phone 8.1\n\n___\n\n## How to use:\n\n**Initialization:**\n* Add reference to MKEncryptor_Interfaces and MKEncryptor_Core\n* In your class (or console app): \n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var modelManager = new MKModelManager(new MKRawDataProviderStatic());\n        var encryptor = new MKEncryptor();\n        \n        ...\n    }\n}\n```\n\n**Show list of all provided ciphers:**\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var modelManager = new MKModelManager(new MKRawDataProviderStatic());\n        var encryptor = new MKEncryptor();\n        \n        foreach (var cipher in encryptor.ProvidedCiphers)\n        {\n            Console.WriteLine(\"{0} Supported keys: {1}\", cipher.DisplayName, MKEnumerableHelper.ArrayToString(cipher.SupportedKeySizes));\n        }\n    }\n}\n```\n\n**Add text or register file, directory (with choosing ciphers):**\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var modelManager = new MKModelManager(new MKRawDataProviderStatic());\n                \n        var camelliaCipher = encryptor.FindCipherBy(\"camellia\", \"bouncy_castle\");\n        var otherCipher = encryptor.ProvidedCiphers.First();\n        \n        var text = new MKEncryptionText(...);\n        text.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(camelliaCipher, MKKeySize.Key256));\n        text.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(otherCipher, MKKeySize.Key256));\n        \n        var file = new MKEncryptionFile(...);\n        file.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(camelliaCipher, MKKeySize.Key256));\n        file.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(otherCipher, MKKeySize.Key256));\n        \n        var directory = new MKEncryptionDir(...);\n        directory.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(camelliaCipher, MKKeySize.Key256));\n        directory.AddUsedCipherAtLastPosition(MKUsedCipher.CreateFrom(otherCipher, MKKeySize.Key256));\n        \n        modelManager.Texts.Add(text);\n        modelManager.Files.Add(file);\n        modelManager.Dirs.Add(directory);       \n        modelManager.SaveChanges()\n    }\n}\n```\n\n**Simple encryption and decryption:**\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var encryptor = new MKEncryptor();\n        var camelliaCipher = encryptor.FindCipherBy(\"camellia\", \"bouncy_castle\");\n        \n        var password = \"my password\";\n        var plainText = \"my secret text\";\n        \n        var encrypted = encryptor.Encrypt(plainText, password, cipher, MKKeySize.Key256);\n        var decrypted = encryptor.Decrypt(encrypted, password, cipher, MKKeySize.Key256);\n        \n        // decrypted == plainText\n    }\n}\n```\n\n**Advanced encryption and decryption (files, directories, texts):**\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var modelManager = new MKModelManager(new MKRawDataProviderStatic());\n        var encryptor = new MKEncryptor();\n        \n        var selectedIndex = 0;\n        var file = modelManager.Files[selectedIndex];\n        \n        var password = \"my secret password\";\n        \n        if (file.State == MKEncryptionState.Decrypted)\n        {\n            encryptor.Encrypt(password, file);            \n        }\n        else\n        {\n            encryptor.Decrypt(password, file);\n        }\n    }\n}\n```\n\n___\n\n**Custom raw data provider:**\n* Implement interface IMKRawDataProvider\n```C#\npublic interface IMKRawDataProvider\n{\n    Task\u003cstring\u003e GetJsonString(string key);\n    Task\u003cbool\u003e SaveJsonString(string key, string json);\n}\n```\n\n* Example of custom file raw data provider:\n```C#\nclass MyFileDataProvider : IMKRawDataProvider\n{\n    public Task\u003cstring\u003e GetJsonString(string key)\n    {\n        return Task.Factory.StartNew(() =\u003e getJsonStringInternal(key));\n    }\n\n    private static string getJsonStringInternal(string key)\n    {\n        try\n        {\n            return File.ReadAllText(key);\n        }\n        catch (Exception)\n        {\n            return string.Empty;\n        }\n    }\n\n    public Task\u003cbool\u003e SaveJsonString(string key, string json)\n    {\n        File.WriteAllText(key, json);\n        return Task.FromResult(true);\n    }\n}\n```\n\n* Use it while creating MKModelManager instance:\n```C#\nclass Program\n{\n    static void Main(string[] args)\n    {\n        var modelManager = new MKModelManager(new MyFileDataProvider());\n        var encryptor = new MKEncryptor();\n        \n        ...\n    }\n}\n```\n\n### Check unit tests for more info","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarfusios%2Fmkencryptor.core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarfusios%2Fmkencryptor.core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarfusios%2Fmkencryptor.core/lists"}