开发者

Determining hash of my own application as it is run?

I want my C# Windows executable to determine its own HASH value. I know how to implement Hash, but how to 开发者_开发知识库determine at run-time?


Not sure if by hash you mean the public key token, or your own hashing algorithm.

With these you can simply get the public key token property from the assembly object:

System.Reflection.Assembly.GetExecutingAssembly(); // Assembly reference
System.Reflection.Assembly.GetEntryAssembly(); // Top level assembly reference

With this you can use your own hashing algorithm:

System.Reflection.Assembly.GetExecutingAssembly().Location // Filename


Assembly.GetExecutingAssembly().Location is the path to your executable. You can read it and compute it's hash with SHA1CryptoServiceProvider or something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜