System.Security.Cryptography.DSASignatureFormatter.CreateSignature C# (CSharp) Method

CreateSignature() public method

public CreateSignature ( byte rgbHash ) : byte[]
rgbHash byte
return byte[]
		public override byte[] CreateSignature (byte[] rgbHash)
		{
			if (dsa == null) {
				throw new CryptographicUnexpectedOperationException (
					Locale.GetText ("missing key"));
			}

			return dsa.CreateSignature (rgbHash);
		}

Usage Example

        /// <summary>
        /// 数字签名处理.
        /// </summary>
        /// <param name="HashToSign"></param>
        /// <param name="DSAKeyInfo"></param>
        /// <param name="HashAlg"></param>
        /// <returns></returns>
        public static byte[] DSASignHash(byte[] HashToSign, DSAParameters DSAKeyInfo, string HashAlg)
        {
            try
            {
                //Create a new instance of DSACryptoServiceProvider.
                DSACryptoServiceProvider DSA = new DSACryptoServiceProvider();

                //Import the key information.
                DSA.ImportParameters(DSAKeyInfo);

                //Create an DSASignatureFormatter object and pass it the
                //DSACryptoServiceProvider to transfer the private key.
                DSASignatureFormatter DSAFormatter = new DSASignatureFormatter(DSA);

                //Set the hash algorithm to the passed value.
                DSAFormatter.SetHashAlgorithm(HashAlg);

                //Create a signature for HashValue and return it.
                return DSAFormatter.CreateSignature(HashToSign);
            }
            catch (CryptographicException e)
            {
                Console.WriteLine(e.Message);

                return null;
            }
        }
All Usage Examples Of System.Security.Cryptography.DSASignatureFormatter::CreateSignature