{"id":22290762,"url":"https://github.com/mberry/makwa-sharp","last_synced_at":"2025-03-25T21:33:23.594Z","repository":{"id":144279772,"uuid":"153238188","full_name":"mberry/Makwa-Sharp","owner":"mberry","description":"C# implementation of the Makwa password hashing algorithm","archived":false,"fork":false,"pushed_at":"2018-10-19T03:39:52.000Z","size":2522,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-13T04:27:16.082Z","etag":null,"topics":["cryptography","hashing","passwords"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mberry.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2018-10-16T07:04:07.000Z","updated_at":"2021-01-18T16:34:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"d1c4a0ca-714d-4da2-877f-3db4083ba60c","html_url":"https://github.com/mberry/Makwa-Sharp","commit_stats":null,"previous_names":["mitchellberry/makwa-sharp"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberry%2FMakwa-Sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberry%2FMakwa-Sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberry%2FMakwa-Sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mberry%2FMakwa-Sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mberry","download_url":"https://codeload.github.com/mberry/Makwa-Sharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236406009,"owners_count":19143666,"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":["cryptography","hashing","passwords"],"created_at":"2024-12-03T17:14:03.512Z","updated_at":"2025-01-30T18:47:26.107Z","avatar_url":"https://github.com/mberry.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MitchellBerry/Makwa-Sharp/master/Docs/makwa-logo.png\"\u003e\n\u003c/p\u003e\n\n# Makwa-Sharp\n\n[![NuGet](https://img.shields.io/nuget/v/Makwa.svg)](https://www.nuget.org/packages/Makwa/1.0.0) [![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://github.com/MitchellBerry/Makwa-Sharp/blob/master/License.md)\n\nA pure C# Makwa implementation with no dependencies. \n\nMakwa was a runner up in the Password Hashing Competition, uniquely has a delegation function which allows hashing to be offloaded onto a third party server without revealing the password.\n\n## Installation\n\n#### Nuget\n    Install-Package Makwa\n\n#### .NET\n\n    dotnet add package Makwa\n\n#### Git\n\n    git clone https://github.com/MitchellBerry/Makwa-Sharp.git\n\n## Usage\n\n#### Basic\n\n```csharp\nusing Makwa;\n\nHasher makwa = Hasher.Create();\nString password = \"hunter2\";\nString hash = makwa.HashPassword(password);\n// hash: SdVTLgfGKck_b211_TG3Uljw178dpAPtw1qILPA_JMm2w54jILdKKQMp\n```\n#### Verify Password\n\n```csharp\nString hash = \"SdVTLgfGKck_b211_TG3Uljw178dpAPtw1qILPA_JMm2w54jILdKKQMp\"\nbool correct_password = makwa.VerifyPassword(password, hash)\n```\n\n#### Custom Parameters\n\n```csharp\nmakwa.Prehashing = false;\nmakwa.Posthashing = 16;\nmakwa.Workfactor = 384;\nmakwa.Hashfunction = new HMACSHA512();\nString hash = makwa.HashPassword(password);\n// hash: SdVTLgfGKck_s307_Qh0ZKgAwQr+ieFauHFm4Vg_3B/H3xbYZZa2Ua2yfK55mA\n```\n\n#### Key Derivation Function Only\n```csharp\nbyte[] input_bytes = new byte[87]; //[0x00, 0x00, 0x00 ...]\nint output_length = 173;\nbyte[] kdf_output = makwa.KDF(input_bytes, output_length);\n```\n\n#### Hash Digest Bytes\n\n```csharp\nbyte[] salt = new byte[16]; //Use an appropriately random input, 16 bytes long\nbyte[] password_bytes = Encoding.UTF8.GetBytes(password);\nbyte[] digest_bytes = makwa.Digest(password_bytes, salt);\n// digest byte array, length is determined by Posthashing value\n```\n\n## Parameters\n\n|     Name     \t|  Type  \t|                                                                                                                                                                                           Effect                                                                                                                                                                                           \t|   Default  \t|\n|:------------:\t|:------:\t|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:\t|:----------:\t|\n|  Prehashing  \t|  bool  \t|                                                                                                                                               Hashes the input prior to the running the main Makwa algorithm. Allows an unlimited input size.                                                                                                                                              \t|    True    \t|\n|  Posthashing \t| ushort \t|                                                                       Hashes the result down to the specified size, the default value of 12 results in a 12 byte digest. A value of 0 applies no post-hashing and the digest will be the full size, values between 1 and 9 are not valid and will raise an exception.                                                                      \t|     12     \t|\n|  Workfactor  \t|  uint  \t|  The number of rounds performed, a higher number will increase hashing time. Work factors are restricted to values w = x * 2\u003csup\u003ey\u003c/sup\u003e, where x = 2 or 3 and y ≥ 0, other values will raise an error suggesting the closest valid value. (See notes below)\t|    4096    \t|\n| Hashfunction \t|  HMAC  \t|                                                                                                                                                              A HMAC object, only HMACSHA256 and HMACSHA512 are valid options.                                                                                                                                                              \t| HMACSHA256 \t|\n\n\n\n## Testing\n\nTesting is setup for Visual Studio, playlists are provided to reduce testing time rather than going through the full set, TestWorkFactor384 will significantly reduce time taken.\nRunning the full test suite should take ~30 mins on an average cpu. The kats.txt file consists of 400 KDF and 2000 Makwa known answer tests.\n\n## Notes\n\n* This implementation enforces specific work factors of the form w = ζ · 2ᵟ, where ζ = 2 or 3, and δ ≥ 0. Some valid work factors: 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384\n\n* The final hash string doesn't differentiate between SHA-256 and SHA-512. If verifying from an unknown source test both algorithms.\n\n* A unique 2048-bit modulus is generated on first use and stored in the libraries folder as a binary file named modulus, generating your own is possible through either OpenSSL or the MakwaPrivateKey class as is testing for primality and correct type. Modulus must be a Blum integer which is the product of 2 primes p \u0026 q of the type: prime ≡ 3 (mod 4).\n\n* A standalone .dll is available [here](https://github.com/MitchellBerry/Makwa-Sharp/releases/latest)\n\n* The use of Pre and Post hashing affects certain features (delegation and fast-path are unaffected):\n\n\u003cp align=\"center\"\u003e\n  \u003cbr\u003e\u003cbr\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/MitchellBerry/Makwa-Sharp/master/Docs/prepostmakwa.png\"\u003e\n\u003c/p\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmberry%2Fmakwa-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmberry%2Fmakwa-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmberry%2Fmakwa-sharp/lists"}