{"id":22343466,"url":"https://github.com/datajuggler/datajuggler.cryptography","last_synced_at":"2026-02-01T09:33:38.164Z","repository":{"id":65356767,"uuid":"429264944","full_name":"DataJuggler/DataJuggler.Cryptography","owner":"DataJuggler","description":"DataJuggler.Cryptography has been updated to .NET 9.","archived":false,"fork":false,"pushed_at":"2024-11-22T23:33:25.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-04T08:29:17.111Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DataJuggler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License/License.txt","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":"2021-11-18T02:08:20.000Z","updated_at":"2024-12-05T16:15:20.000Z","dependencies_parsed_at":"2024-11-20T13:47:51.287Z","dependency_job_id":null,"html_url":"https://github.com/DataJuggler/DataJuggler.Cryptography","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DataJuggler/DataJuggler.Cryptography","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataJuggler%2FDataJuggler.Cryptography","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataJuggler%2FDataJuggler.Cryptography/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataJuggler%2FDataJuggler.Cryptography/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataJuggler%2FDataJuggler.Cryptography/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DataJuggler","download_url":"https://codeload.github.com/DataJuggler/DataJuggler.Cryptography/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DataJuggler%2FDataJuggler.Cryptography/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267792751,"owners_count":24144931,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-12-04T08:16:10.925Z","updated_at":"2026-02-01T09:33:38.159Z","avatar_url":"https://github.com/DataJuggler.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nuget Package Name: DataJuggler.Cryptography\n\nThis version is for .NET 9. Use a 8.x version for .NET 8, a 7.x for .NET 7.\n\n# News\n\nUpdate 11.21.2025: DataJuggler.Cryptography has been updated to .NET 10.\n\nUpdate 11.19.2024: DataJuggler.Cryptography has been updated to .NET 9.\n\nUpdate 11.20.2023: DataJuggler.UltimateHelper was updated.\n\nUpdate 11.14.2023: DataJuggler.Cryptography has been updated to .NET 8.\n\nUpdate 8.13.2023: DataJuggler.UltimateHelper was updated.\n\nUpdate: 7.16.2023\nI opened this project for the first time in a long time, and discovered the constructor for \nRfc2898DeriveBytes was deemed obsolete. I changed the HashAlgorithm name to \nHashAlgorithmName.SHA512. This probably breaks any existing users, and for that I apologize.\n\n# DataJuggler.Cryptography\nThis is a port of CryptographyHelper from DataJuggler.Core.UltimateHelper for dot net framework. This class uses System.Security.AesManaged for encrypt / decryption and Konscious.Security.Cryptography.Argon2 by Keef Aragon for password hashing.  \n\nThis is a copy of CryptographyHelper class from DataJuggler.Core.UltimateHelper for\nthe .Net Framework. Originally I added this class to the Dot Net Core version\nof UltimateHelper called DataJuggler.UltimateHelper.Core, but Nuget needs to add about\n50 or 60 packages for Argon2, so I moved this class to its own library.\n\nTo use this package: \n\nInstall Package: DataJuggler.Cryptography\n\nThere are two main functions for the project:\n1. Encryption / Decryption, with or without an encryption key using System.Security.Cryptography.AesManaged\n2. Password Hashing using Konscious.Security.Cryptography.Argon2\n\nTo use in your own projects after you install the package via Nuget\n\nusing DataJuggler.Cryptography;\n\nThere is a constant available called DefaultPassword. The Encryption / Decryption methods and the GeneratePasswordHash\nmethods contain overrides that allow you to supply your own keyCode or you may use the DefaultPassword:\n\n# Default Password\n\npublic const string DefaultPassword = \"NotASecret\";\n\n# Encryption\n\npublic static string EncryptString(string stringToEncrypt, string password)\n\nTo encrypt a string, call the EncryptString method\n\nTo use your own password\n\nstring encrypted = CryptographyHelper.EncryptString(stringToEncrypt, password);\n\nTo use default password\n\nstring encrypted = CryptographyHelper.EncryptString(stringToEncrypt);\n\nThe encryption algorithm will return a different result every time you encrypt a string. \n\n# Decryption\n\npublic static string DecryptString(string stringToDecrypt, string password)\n\nYou muse use the same password key to decrypt a string that you used to encrypt.\n\nTo use your own password\n\nstring decrypted = CryptographyHelper.DecryptString(stringToDecrypt, password);\n\nTo use default password\n\nstring decrypted = CryptographyHelper.DecryptString(stringToDecrypt);\n\n# Password Hashing\n\npublic static string GeneratePasswordHash(string password, string keyCode)\n\nThis method hashes the password using Konscious.Security.Cryptography's implementation of Argon2 by Keef Aragon.\n\n# Salt\n\nSource: https://learncryptography.com/hash-functions/password-salting\n\nPassword salting is the process of securing password hashes from something called a Rainbow Table attack. The problem with non-salted passwords is that they do not have a property that is unique to themselves – that is, if someone had a precomputed rainbow table of common password hashes, they could easily compare them to a database and see who had used which common password. A rainbow table is a pre-generated list of hash inputs to outputs, to quickly be able to look up an input (in this case, a password), from its hash. However, a rainbow table attack is only possible because the output of a hash function is always the same with the same input.\n\n(I didn't want to try and define salt because I knew I would not do it justice).\n\nThe salt is returned with the password separated by 4 | pipe characters.\n\nYou can decrypt the encrypted password hash to determine the password hash and salt, but you\ncannot decrypt from password hash back to the original password.\n\n# To generate a Password Hash using your own keyCode\n\nstring passwordHash = CryptographyHelper.GeneratePasswordHash(password, keyCode);\n\n# To generate a Password Hash using your the default keyCode\n\nstring passwordHash = CryptographyHelper.GeneratePasswordHash(password);\n\n# VerifyHash\n\npublic static bool VerifyHash(string userTypedPassword, string keyCode, string storedPasswordHash)\n\nTo implement login functionality you need to verify the user typed in password can verify against your stored password hash.\n\nIf you supplied a keyCode to generate a password hash you must supply the same keyCode to verify.\n\nTo verify using your own keyCode\n\nbool verifiedLogin = CryptographyHelper.VerifyHash(userTypedInPassword, keyCode, storedPasswordHash);\n\nTo verify using default keyCode\n\nbool verifiedLogin = CryptographyHelper.VerifyHash(userTypedInPassword, storedPasswordHash);\n\n# How VerifyHash works\n\nYour storedPasswordHash is first decrypted using either the supplied keyCode or the DefaultPassword of NotASecret depending on which override you called.\n\nThe result will then contain a string made up of the passwordHash followed by a separator of 4 pipe characters in a row |||| and then the salt.\n\nThis is an example, just to show the decrypted text of the password hash uses Unicode characters\n\n憭紷줧悐纴Ꮄ⫘||||䣿別坵ࠀ恆쁿냞 \n\nNext the PasswordHash is determined from the left half of the 4 pipe characters.\n\nThe salty string is the characters after the 4 pipe characters.\n\nBoth salt and storedHash are both byte arrays.\n\nbyte[] salt = null;\u003cbr/\u003e\nbyte[] storedHash = null;\n\n// get the index\u003cbr/\u003e\nint index = decryptedHash.IndexOf(\"||||\");\n\n// if the index was found\u003cbr/\u003e\nif (index \u003e= 0)\u003cbr/\u003e\n{\u003cbr/\u003e\n    \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;// get the password\u003cbr/\u003e\n    \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;password = decryptedHash.Substring(0, index);\u003cbr/\u003e\n    \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;salty = decryptedHash.Substring(index + 4);\u003cbr/\u003e\n    \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;salt = Encoding.Unicode.GetBytes(salty);\u003cbr/\u003e\n    \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;storedHash = Encoding.Unicode.GetBytes(password);\u003cbr/\u003e\n}\u003cbr/\u003e\n\u003cbr/\u003e\nAt this point, the salt and storedHash should be loaded, so we can call another verifyHash override.\n\npublic static bool VerifyHash(string password, byte[] salt, byte[] storedHash)\n\nThe verifyHash method creates a new passwordHash and compares it to the storedHash using Linq.\n\n// generate the loginHash again\u003cbr/\u003e\u003cbr/\u003e\nvar newHash = HashPassword(password,  salt);\u003cbr/\u003e\n\n// set the return value\u003cbr/\u003e\nverified = storedHash.SequenceEqual(newHash);\u003cbr/\u003e\n\u003cbr/\u003e\nI just built a Blazor.Crypto sample, but I wanted to publish the Nuget package first.\n\nThe sample is located here:\n\nhttps://github.com/DataJuggler/Blazor.Crypto\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajuggler%2Fdatajuggler.cryptography","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatajuggler%2Fdatajuggler.cryptography","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatajuggler%2Fdatajuggler.cryptography/lists"}