#region ========================================================================= USING ===================================================================================== using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Security.Cryptography; #endregion namespace Nemera.Presentation.Api.Fixtures.Core.Plugins; /// /// Fixture class for computing the SHA-256 checksums of bundled plugin files. /// [ExcludeFromCodeCoverage] public class BundledPluginFileHashFixture { /// /// Computes the SHA-256 checksum of the file at , in the uppercase hexadecimal form the trust manifest uses. /// /// The path of the file to hash. /// The uppercase hexadecimal SHA-256 checksum. public string Create(string path) { // Convert.ToHexString returns uppercase hexadecimal, which is the form the trust manifest uses. using (FileStream fileStream = new(path, FileMode.Open, FileAccess.Read, FileShare.Read)) return Convert.ToHexString(SHA256.HashData(fileStream)); } }