public SignHash ( byte rgbHash, string str ) : byte[] | ||
rgbHash | byte | The hash value of the data to be signed. |
str | string | The name of the hash algorithm used to create the hash value of the data. |
return | byte[] |
public byte[] SignHash(byte[] rgbHash, string str)
{
if (rgbHash == null)
throw new ArgumentNullException(nameof(rgbHash));
if (PublicOnly)
throw new CryptographicException(SR.Cryptography_CSP_NoPrivateKey);
int calgHash = CapiHelper.NameOrOidToHashAlgId(str);
if (rgbHash.Length != _sha1.HashSize / 8)
throw new CryptographicException(string.Format(SR.Cryptography_InvalidHashSize, "SHA1", _sha1.HashSize / 8));
return CapiHelper.SignValue(
SafeProvHandle,
SafeKeyHandle,
_parameters.KeyNumber,
CapiHelper.CALG_DSS_SIGN,
calgHash,
rgbHash);
}
void Sign(String[] args) { if (args.Length != 1) { Usage(); return; } try { String productCode = args[0]; byte[] pcode = StringUtils.Str2Bytes(productCode); for (int i = 0; i < 1; ++i) { DSAParameters dsap = CryptographyParams.DSAP; dsap.X = X; DSACryptoServiceProvider dsa = new DSACryptoServiceProvider(512); dsa.ImportParameters(dsap); String oid = CryptoConfig.MapNameToOID(LicensingStrings.SHA1); byte[] acode = dsa.SignHash(pcode, oid); String activationCode = StringUtils.Bytes2Str(acode); System.Console.Out.WriteLine(activationCode); } } catch (Exception e) { System.Console.Out.WriteLine("Error: {0}\n", e.Message); } }