Change Executable Hash Algorithm

89 Views Asked by At

We have an application build in .NET Framework 4.8, and for security issue we need to change the Hash Algorithm from SHA-1 to SHA-256.

We find this hash algorithm trough ILSPY( as you can see on the image).

I have also downloaded Ilspy source code and I find that the hash algorithm was retrieved from the code AssemblyDefinition.HashAlgorithm.

enter image description here

For solve this issue I tried to:

  • Sign ClickOneManifest
  • Sign .exe with certificate
  • Obfuscate the code

Without success :(

How we can change hash Algorithm of a dll?

I tried, to sign the dll with certificate, obfuscate with dotfuscator, sign the manifest. and also try this Override default HashAlgorithm.Create() but seems don't work.

1

There are 1 best solutions below

0
Jon Skeet On BEST ANSWER

You can specify it using AssemblyAlgorithmIdAttribute like this:

[assembly:AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA256)]

(Note that the value is a System.Configuration.Assemblies.AssemblyHashAlgorithm, not a System.Reflection.AssemblyHashAlgorithm, annoyingly.)