[英]HTTP Digest Authentication - Share MD5 instance between multiple http requests
I have my own HTTP request class which I am using it as a client to send an HTTP requests to some remote servers. 我有自己的HTTP请求类,将其用作客户端以将HTTP请求发送到某些远程服务器。 I am implementing an HTTP digest authentication and using MD5 instance in order to preform the hash algorithm . 我正在实现HTTP摘要认证,并使用MD5实例来执行哈希算法。 I would like to know what is the efficient way to store the MD5 instance ? 我想知道什么是存储MD5实例的有效方法? I thought about these options: 我考虑了以下选项:
Every request will hold a MD5 instance, so every time that request are being sent we will do : m_md5 = MD5.Create();
每个请求都将保存一个MD5实例,因此每次发送该请求时,我们都会这样做: m_md5 = MD5.Create();
How expensive is the 'Create' process ? “创建”过程的成本是多少?
Thnaks. Thnaks。
As Oguz Ozgul Said the second optiond doesn't possible since MD5 doesn't thread-safeas we can see here : 正如Oguz Ozgul 说的那样,第二个选项是不可能的,因为MD5不是线程安全的,我们可以在这里看到:
Any public static (Shared in Visual Basic) members of this type are thread safe. 此类型的任何公共static(在Visual Basic中为Shared)成员都是线程安全的。 Any instance members are not guaranteed to be thread safe 不保证任何实例成员都是线程安全的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.