SHA1

[System.Runtime.InteropServices.ComVisible(true)]
public abstract class SHA1 : HashAlgorithm
{
    protected SHA1()
    {
        HashSizeValue = 160;
    }

    new static public SHA1 Create()
    {
        return Create("System.Security.Cryptography.SHA1");
    }

    new static public SHA1 Create(String hashName)
    {
        return (SHA1)CryptoConfig.CreateFromName(hashName);
    }
}



[System.Runtime.InteropServices.ComVisible(true)]
public class SHA1Managed : SHA1
{
    public SHA1Managed()
    {
#if FEATURE_CRYPTO
            if (CryptoConfig.AllowOnlyFipsAlgorithms)
                throw new InvalidOperationException(Environment.GetResourceString("Cryptography_NonCompliantFIPSAlgorithm"));
            Contract.EndContractBlock();
#endif // FEATURE_CRYPTO

        _stateSHA1 = new uint[5];
        _buffer = new byte[64];
        _expandedBuffer = new uint[80];

        InitializeState();
    }
}


[System.Security.Permissions.HostProtection(MayLeakOnAbort
= true)] public sealed class SHA1Cng : SHA1 { private BCryptHashAlgorithm m_hashAlgorithm; public SHA1Cng() { Contract.Ensures(m_hashAlgorithm != null); m_hashAlgorithm = new BCryptHashAlgorithm(CngAlgorithm.Sha1, BCryptNative.ProviderName.MicrosoftPrimitiveProvider); } protected override void Dispose(bool disposing) { try { if (disposing) { m_hashAlgorithm.Dispose(); } } finally { base.Dispose(disposing); } } }

 

posted @ 2016-11-03 22:17  茗::流  阅读(197)  评论(0)    收藏  举报
如有雷同,纯属参考。如有侵犯你的版权,请联系我。