Why are classes like SHA1Managed, SHA256Managed hidden from my Intellisense?

人走茶凉 提交于 2021-01-28 11:21:10

问题


When I go to the System.Security.Cryptography namespace, I can only see SHA1, SHA256, HMACSHA1 etc classes there.

But actually, there is a SHA1Managed class, as well as SHA256Managed, which I don't see? When I write it out manually - everything works as expected.

Is this hidden intentionally? And what's the difference between simply instancing a managed version of those, versus for example calling their factory methods (SHA1.Create() or SHA256.Create())? Are they the same thing?


回答1:


Can't give you an answer for the weird IntelliSense problem but have a look at the SHA1 and SHA1Managed implementations. SHA1 is just a base class. The implementation is exactly the same in this case. It has something to do with the FIPS certification. Managed versions don't use the native crypto libraries and therefor are not FIPS certified. There is a registry setting (FipsAlgorithmPolicy) for customers which enforces FIPS compliance. If the registry setting is turned on you can't use the managed classes.

In your case it does not make any difference if you instanciate SHA1Managed or use SHA1.Create(). But it does make a difference if you need to meet the FIPS certification.



来源:https://stackoverflow.com/questions/65036928/why-are-classes-like-sha1managed-sha256managed-hidden-from-my-intellisense

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!