phdesign / NppToolBucket

Plugin of assorted tools for Notepad++ including Multi-line search and replace.
http://phdesign.com.au/npptoolbucket/
Apache License 2.0
53 stars 11 forks source link

Wrong SHA1 checksum for latin letters #32

Open adammankowski1 opened 3 years ago

adammankowski1 commented 3 years ago

Hello,

I found out that NppToolBucket generates wrong SHA1 checksum for latin letters (tried with: "ł").

Letter "ł" checksum sha1 d8d824647b9ebeea3ede7cf0f9f5d2405881bf20 C# D50591FF745CC83091F4EE12B2EE702CB24B0B45 ToolBucket

Letter "l" checksum sha1 07c342be6e560e7f43842e2e21b774e61d85f047 C# 07C342BE6E560E7F43842E2E21B774E61D85F047 ToolBucket

The code I generated checksum in the C#:

using (var cryptoProvider = new SHA1CryptoServiceProvider())
{
    byte[] messageBytes = Encoding.UTF8.GetBytes("ł");
    //d8d824647b9ebeea3ede7cf0f9f5d2405881bf20
    var hash = BitConverter.ToString(cryptoProvider.ComputeHash(messageBytes)).ToLower().Replace("-", string.Empty);
}

Online sha1 checksum generator like Online MD5 Hash Generator & SHA1 returns the same checksum as C# methods.

thabing commented 2 years ago

I was having a similar problem, and I found that if I changed the Encoding to ANSI prior to generating the checksum, it gave me the expected result.