Skip to content

Commit

Permalink
fix: hashing wrong assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
Clazex committed Jan 26, 2023
1 parent b1693fc commit bf9b6df
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Osmi/Utils/AssemblyUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public static FileStream ReadAsStream(this Assembly self) =>
/// <param name="self">The assembly to get hash from</param>
/// <param name="length">Length of hash string to be preserved</param>
/// <returns>The <see cref="SHA1"/> hash string</returns>
public static string GetHash(this Assembly self, int length = 7) {
using var hasher = SHA1.Create();
byte[] bytes = File.ReadAllBytes(Assembly.GetExecutingAssembly().Location);
return BitConverter.ToString(hasher.ComputeHash(bytes))
.Replace("-", "").Substring(0, length).ToLowerInvariant();
}
public static string GetHash(this Assembly self, int length = 7) =>
HashStream.ComputeHashString(
File.OpenRead(self.Location),
SHA1.Create()
)
.Substring(0, length)
.ToLowerInvariant();

/// <summary>
/// Gets the version with <see cref="SHA1"/> hash of specified assembly,
Expand Down

0 comments on commit bf9b6df

Please sign in to comment.