< Summary

Information
Class: Elsa.Identity.Contracts.ISecretHasher
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Contracts/ISecretHasher.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 57
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GenerateSalt(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Contracts/ISecretHasher.cs

#LineLine coverage
 1using System.Security.Cryptography;
 2using Elsa.Identity.Models;
 3
 4namespace Elsa.Identity.Contracts;
 5
 6/// <summary>
 7/// Represents a secret hasher.
 8/// </summary>
 9public interface ISecretHasher
 10{
 11    /// <summary>
 12    /// Hashes the secret.
 13    /// </summary>
 14    /// <param name="secret">The secret to hash.</param>
 15    /// <returns>The hashed secret.</returns>
 16    HashedSecret HashSecret(string secret);
 17
 18    /// <summary>
 19    /// Hashes the secret.
 20    /// </summary>
 21    /// <param name="secret">The secret to hash.</param>
 22    /// <param name="salt">The salt to use.</param>
 23    /// <returns>The hashed secret.</returns>
 24    HashedSecret HashSecret(string secret, byte[] salt);
 25
 26    /// <summary>
 27    /// Hashes the secret.
 28    /// </summary>
 29    /// <param name="secret">The secret to hash.</param>
 30    /// <param name="salt">The salt to use.</param>
 31    /// <returns>The hashed secret.</returns>
 32    byte[] HashSecret(byte[] secret, byte[] salt);
 33
 34    /// <summary>
 35    /// Verifies the secret.
 36    /// </summary>
 37    /// <param name="clearTextSecret">The secret to verify.</param>
 38    /// <param name="secret">The hashed secret.</param>
 39    /// <param name="salt">The salt.</param>
 40    /// <returns>True if the secret is valid, otherwise false.</returns>
 41    bool VerifySecret(string clearTextSecret, string secret, string salt);
 42
 43    /// <summary>
 44    /// Verifies the secret.
 45    /// </summary>
 46    /// <param name="clearTextSecret">The secret to verify.</param>
 47    /// <param name="hashedSecret">The hashed secret.</param>
 48    /// <returns>True if the secret is valid, otherwise false.</returns>
 49    bool VerifySecret(string clearTextSecret, HashedSecret hashedSecret);
 50
 51    /// <summary>
 52    /// Generates a salt.
 53    /// </summary>
 54    /// <param name="saltSize">The size of the salt.</param>
 55    /// <returns>The salt.</returns>
 056    byte[] GenerateSalt(int saltSize = 32) => RandomNumberGenerator.GetBytes(saltSize);
 57}

Methods/Properties

GenerateSalt(System.Int32)