{"id":15011609,"url":"https://github.com/alexfariakof/easycryptosalt","last_synced_at":"2026-01-21T20:39:28.801Z","repository":{"id":242599122,"uuid":"810007432","full_name":"alexfariakof/EasyCryptoSalt","owner":"alexfariakof","description":"Biblioteca simples e eficiente para operações criptográficas em .NET. Usando o algoritmo SHA-256, juntamente com a capacidade de comparar hashes utilizando uma chave e um salt.","archived":false,"fork":false,"pushed_at":"2024-06-18T03:58:15.000Z","size":115,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T04:12:37.672Z","etag":null,"topics":["codeql","cryptography","cryptography-algorithms","csharp","dotnet","dotnet-core","gitactions-workflow","githubpackages","nuget-package","reportgenerator","salt","sha256-crypt","singleton-pattern","sonarcloud","xunit","xunit-tests"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/EasyCryptoSalt/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexfariakof.png","metadata":{"files":{"readme":"README-en.md","changelog":null,"contributing":null,"funding":null,"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":"2024-06-03T21:53:11.000Z","updated_at":"2024-06-18T03:53:46.000Z","dependencies_parsed_at":"2024-06-14T21:22:31.828Z","dependency_job_id":"56b4f5e5-ef81-499c-b8df-cd22009a0b16","html_url":"https://github.com/alexfariakof/EasyCryptoSalt","commit_stats":{"total_commits":102,"total_committers":2,"mean_commits":51.0,"dds":0.0980392156862745,"last_synced_commit":"9da9da0913889d7462b764d19b841410e64da084"},"previous_names":["alexfariakof/easycryptosalt"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfariakof%2FEasyCryptoSalt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfariakof%2FEasyCryptoSalt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfariakof%2FEasyCryptoSalt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexfariakof%2FEasyCryptoSalt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexfariakof","download_url":"https://codeload.github.com/alexfariakof/EasyCryptoSalt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247974731,"owners_count":21026742,"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":["codeql","cryptography","cryptography-algorithms","csharp","dotnet","dotnet-core","gitactions-workflow","githubpackages","nuget-package","reportgenerator","salt","sha256-crypt","singleton-pattern","sonarcloud","xunit","xunit-tests"],"created_at":"2024-09-24T19:41:20.295Z","updated_at":"2026-01-21T20:39:28.759Z","avatar_url":"https://github.com/alexfariakof.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Leia esta página em português](https://github.com/alexfariakof/EasyCryptoSalt/blob/main/README.md)\n\n# EasyCryptoSalt\n\nEasyCryptoSalt is a simple and efficient library for cryptographic operations in .NET. It provides functionalities for secure hashing using the SHA-256 hashing algorithm, along with the ability to compare hashes using a key and a salt.\n\n## Key Features\n\n* This version uses .NET Standard 2.0, making it reusable across various .NET platforms.\n* Secure Hashing: Generate secure hashes using the SHA-256 hash algorithm.\n* Hash Comparison: Easily verify if plain text matches the provided hash.\n* Additional Security with Salt: Use an additional salt to enhance the security of generated hashes.\n\n## Installation\n\nTo install the NuGet package `EasyCryptoSalt`, execute the following command in the NuGet Package Manager Console:\n\n```powershell\n  dotnet add package EasyCryptoSalt --version 1.0.3\n```\n\n## Configuration\n\nEnsure that the appsettings.json file contains the CryptoConfigurations section with the necessary keys:\n\n```json\n{\n   \"CryptoConfigurations\": {\n        \"Key\": \"Exemplo de Chave `^AOUWNW16h*634+=tq51#2fa8091$2jnsais71298\u003eshsady|==\",\n        \"AuthSalt\": \"Exemplo de Auth salt ``àadskldjlskjdlk\\gwt257__1816!?}[oap725-1%\"\n   }\n}\n```\n\n## Example Usage Mode 2\n\n```csharp  \nusing EasyCryptoSalt;\n\n// Create an instance of Crypto\nvar crypto = Crypto.Instance;\n\n// Generate a secure hash\nstring hashedText = crypto.Encrypt(\"Texto a ser hashado\");\n\n// Verify if a plain text matches a hash\nbool isMatch = crypto.Verify(\"Texto a ser verificado\", hashedText);\n```\n\n## Exemplo de Uso Modo 2\n\n```csharp\n#program.cs\nusing EasyCryptoSalt;\n\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.Configure\u003cCryptoOptions\u003e(configuration.GetSection(\"CryptoConfigurations\"));\nbuilder.Services.AddSingleton\u003cICrypto, Crypto\u003e();\n\nvar app = builder.Build();      \napp.Run();\n\n#ExampleClass.cs \nusing EasyCryptoSalt;\n\npublic class ExampleClass\n{\n  private readonly ICrypto _crypto;\n  public ExampleClass(ICrypto crypto)\n  {\n    _crypto = crypto;\n  }\n\n  public void UseCrypto()\n  {\n    // Generate a secure hash\n    string hashedText = crypto.Encrypt(\"Texto a ser hashado\");\n\n    // Verify if a plain text matches a hash\n    bool isMatch = crypto.Verify(\"Texto a ser verificado\", hashedText);\n  }\n}        \n```\n\n## Classe CryptoOptions\n\n```csharp\npublic class CryptoOptions\n{\n    public string Key { get; set; }\n    public string AuthSalt { get; set; }\n}\n```\n\n## Crypto Class\n\n### Description\n\nThe Crypto class is responsible for performing cryptographic operations, including generating hashes with SHA-256 and comparing hashes using a key and a salt.\n\n\n### Properties\n\n* Instance: A static property that returns a singleton instance of the Crypto class.\n\n\n### Constructors\n\n* Crypto(): Private constructor that initializes the key and salt from the appsettings.json configuration file.\n* Crypto(IOptions\u003cCryptoOptions\u003e options): Public constructor that initializes the key and salt from the provided options in the appsettings.json configuration file.\n\n### Methods\n\n```csharp\npublic string Encrypt(string input)\n```\n\u003e * Description: Generates a hash with salt for the provided input.\n\u003e * Parameters:\n\u003e input (string): Text to be hashed.\n\u003e * Returns:\n\u003e string: Hash with salt in Base64 format.\n\n```csharp\npublic bool Verify(string plainText, string hash)\n```\n\u003e * Description: Verifies if the provided plain text matches the provided hash.\n\u003e * Parameters:\n     plainText (string): Plain text to be verified.\n     hash (string): Hash for comparison.\n\u003e * Returns:\n    bool: Returns true if the plain text generates the same hash; otherwise, false.\n\n```csharp\nprivate byte[] GenerateSalt()\n```\n\n\u003e * Description: Generates a random salt based on the Auth Salt key defined in appsettings.json.\n\u003e * Returns:\n    byte[]: Random salt.\n\n## Notes:\n\n* Ensure to properly configure the key and salt in the appsettings.json file to ensure the proper security of generated hashes.\n\n    ```json\n    {\n      \"CryptoConfigurations\": {\n        \"Key\": \"exemplo de Chave \",\n        \"AuthSalt\": \"exemplo de Auth salt\"\n      }\n    }\n    ```\n\n* This library is designed to be easy to use and offer robust security for your cryptographic needs in .NET.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexfariakof%2Feasycryptosalt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexfariakof%2Feasycryptosalt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexfariakof%2Feasycryptosalt/lists"}