PKCS1MaskGenerationMethod.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Security / Cryptography / PKCS1MaskGenerationMethod.cs / 1 / PKCS1MaskGenerationMethod.cs

                            // ==++== 
//
//   Copyright (c) Microsoft Corporation.  All rights reserved.
//
// ==--== 

namespace System.Security.Cryptography { 
[System.Runtime.InteropServices.ComVisible(true)] 
    public class PKCS1MaskGenerationMethod : MaskGenerationMethod
    { 
        private String HashNameValue;

        //
        // public constructors 
        //
 
        public PKCS1MaskGenerationMethod() { 
            HashNameValue = "SHA1";
        } 

        //
        // public properties
        // 

        public String HashName { 
            get { return HashNameValue; } 
            set {
                HashNameValue = value; 
                if (HashNameValue == null) {
                    HashNameValue = "SHA1";
                }
            } 
        }
 
        // 
        // public methods
        // 

        public override byte[] GenerateMask(byte[] rgbSeed, int cbReturn)
        {
            HashAlgorithm hash = (HashAlgorithm) CryptoConfig.CreateFromName(HashNameValue); 
            byte[] rgbCounter = new byte[4];
            byte[] rgbT = new byte[cbReturn]; 
 
            uint counter = 0;
            for (int ib=0; ib _hash.Length) { 
                    Buffer.BlockCopy(_hash, 0, rgbT, ib, _hash.Length);
                } else { 
                    Buffer.BlockCopy(_hash, 0, rgbT, ib, rgbT.Length - ib);
                }
                ib += hash.Hash.Length;
            } 
            return rgbT;
        } 
    } 
}


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK