System.Security.Cryptography.RSAPKCS1SignatureFormatter.SetHashAlgorithm C# (CSharp) Method

SetHashAlgorithm() public method

public SetHashAlgorithm ( string strName ) : void
strName string
return void
		public override void SetHashAlgorithm (string strName) 
		{
			hash = HashAlgorithm.Create (strName);
		}
	

Usage Example

        public DigitalSignatureCreationResult Sign(DigitalSignatureCreationArguments arguments)
        {
            var res = new DigitalSignatureCreationResult();
            try
            {
                var rsaProviderReceiver = new RSACryptoServiceProvider();
                rsaProviderReceiver.FromXmlString(arguments.PublicKeyForEncryption.ToString());
                var encryptionResult = rsaProviderReceiver.Encrypt(Encoding.UTF8.GetBytes(arguments.Message), false);
                var hashed = _hashingService.Hash(Convert.ToBase64String(encryptionResult));

                var rsaProviderSender = new RSACryptoServiceProvider();
                rsaProviderSender.FromXmlString(arguments.FullKeyForSignature.ToString());
                var signatureFormatter = new RSAPKCS1SignatureFormatter(rsaProviderSender);
                signatureFormatter.SetHashAlgorithm(_hashingService.HashAlgorithmCode());
                var signature = signatureFormatter.CreateSignature(hashed.HashedBytes);

                res.Signature = signature;
                res.CipherText = Convert.ToBase64String(encryptionResult);
                res.Success = true;
            }
            catch (Exception ex)
            {
                res.ExceptionMessage = ex.Message;
            }

            return res;
        }
All Usage Examples Of System.Security.Cryptography.RSAPKCS1SignatureFormatter::SetHashAlgorithm