< Summary

Information
Class: RoleRadar.Domain.Common.Sha256Hasher
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Common/Sha256Hasher.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 27
Line coverage: 100%
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
ComputeLowerHex(...)100%11100%
ComputeLowerHex(...)100%11100%

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Common/Sha256Hasher.cs

#LineLine coverage
 1using System.Security.Cryptography;
 2using System.Text;
 3
 4namespace RoleRadar.Domain.Common;
 5
 6public static class Sha256Hasher
 7{
 8    /// <summary>
 9    /// Computes the lowercase hex SHA-256 of the UTF-8 bytes of the supplied string.
 10    /// </summary>
 11    public static string ComputeLowerHex(string content)
 12    {
 1371213        ArgumentNullException.ThrowIfNull(content);
 1371214        var utf8Bytes = Encoding.UTF8.GetBytes(content);
 1371215        return ComputeLowerHex(utf8Bytes);
 16    }
 17
 18    /// <summary>
 19    /// Computes the lowercase hex SHA-256 of the supplied byte span.
 20    /// </summary>
 21    public static string ComputeLowerHex(ReadOnlySpan<byte> bytes)
 22    {
 1371223        Span<byte> digest = stackalloc byte[SHA256.HashSizeInBytes];
 1371224        SHA256.HashData(bytes, digest);
 1371225        return Convert.ToHexStringLower(digest);
 26    }
 27}