System.Security.Cryptography.RSACryptoServiceProvider.SignHash C# (CSharp) Метод

SignHash() приватный Метод

Computes the hash value of a subset of the specified byte array using the specified hash algorithm, and signs the resulting hash value.
private SignHash ( byte rgbHash, int calgHash ) : byte[]
rgbHash byte The input data for which to compute the hash
calgHash int The hash algorithm to use to create the hash value.
Результат byte[]
        private byte[] SignHash(byte[] rgbHash, int calgHash)
        {
            Debug.Assert(rgbHash != null);

            return CapiHelper.SignValue(
                SafeProvHandle,
                SafeKeyHandle,
                _parameters.KeyNumber,
                CapiHelper.CALG_RSA_SIGN,
                calgHash,
                rgbHash);
        }

Same methods

RSACryptoServiceProvider::SignHash ( byte hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding ) : byte[]
RSACryptoServiceProvider::SignHash ( byte rgbHash, string str ) : byte[]

Usage Example

        /// <summary>
        /// Creates a base64 encoded signature for the SHA-256 hash of the specified data.
        /// </summary>
        /// <param name="data">The data to hash and sign. Must not be null.</param>
        /// <returns>The base-64 encoded signature.</returns>
        public string CreateSignature(byte[] data)
        {
            data.ThrowIfNull(nameof(data));

            using (var hashAlg = SHA256.Create())
            {
                byte[] assertionHash = hashAlg.ComputeHash(data);
#if NETSTANDARD
                var sigBytes = key.SignHash(assertionHash, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
#else
                var sigBytes = key.SignHash(assertionHash, Sha256Oid);
#endif
                return(Convert.ToBase64String(sigBytes));
            }
        }
All Usage Examples Of System.Security.Cryptography.RSACryptoServiceProvider::SignHash