Tempest.RSACrypto.HashAndSign C# (CSharp) Method

HashAndSign() public method

public HashAndSign ( string hashAlg, byte data, int offset, int count ) : byte[]
hashAlg string
data byte
offset int
count int
return byte[]
        public byte[] HashAndSign(string hashAlg, byte[] data, int offset, int count)
        {
            if (hashAlg == null)
                throw new ArgumentNullException ("hashAlg");
            if (data == null)
                throw new ArgumentNullException ("data");

            #if !SILVERLIGHT
            var hasher = CryptoConfig.CreateFromName (hashAlg) as HashAlgorithm;
            #else
            HashAlgorithm hasher = null;
            switch (hashAlg) {
                case "SHA1":
                    hasher = new SHA1Managed();
                    break;

                case "SHA256":
                    hasher = new SHA256Managed();
                    break;
            }
            #endif

            if (hasher == null)
                throw new ArgumentException ("Hash algorithm not found", "hashAlg");

            return this.rsaCrypto.SignData (data, offset, count, hashAlg);
        }