(何时)是否需要调用SHA1Managed.Initialize()?

时间:2015-10-07 21:30:04

标签: c#

SHA1Managed.Initialize()实际上做了什么?什么时候打电话呢? The documentation非常稀疏。

1 个答案:

答案 0 :(得分:0)

来自CoreCLR:

 [System.Security.SecuritySafeCritical]  // auto-generated
    public override void Initialize() {
        if (_safeHashHandle != null && !_safeHashHandle.IsClosed)
            _safeHashHandle.Dispose();

        // _CreateHash will check for failures and throw the appropriate exception
        _safeHashHandle = Utils.CreateHash(Utils.StaticProvHandle, Constants.CALG_SHA1);
    }

它看起来被称为HashAlgorihthm方法的标准实现的一部分,并且看起来在正常使用期间不需要直接调用它。