CryptoSys PKI Pro Manual

Sig.SignData Method

Compute a signature value over data in a byte array.

Syntax

[C#]
public static string SignData(
   byte[] data,
   string privateKeyFile,
   string password,
   SigAlgorithm sigAlg,
   Sig.SigOptions sigOpts = Sig.SigOptions.Default,
   Sig.Encoding sigEncoding = Sig.Encoding.Default 
)
[VB]
Public Shared Function SignData (
   data As Byte(),
   privateKeyFile As String,
   password As String,
   sigAlg As SigAlgorithm,
   Optional sigOpts As Sig.SigOptions = Sig.SigOptions.Default,
   Optional sigEncoding As Sig.Encoding = Sig.Encoding.Default 
) As String

Parameters

data  Byte
input data to be signed
privateKeyFile  String
Name of private key file (or a string containing the key in PEM format, or an internal private key)
password  String
Password for the private key, if encrypted
sigAlg  SigAlgorithm
Signature algorithm to be used
sigOpts  Sig.SigOptions  (Optional)
(optional) Options for ECDSA and RSA-PSS signatures
sigEncoding  Sig.Encoding  (Optional)
Optional encodings for output [default=base64]

Return Value

The encoded signature, or an empty string on error

Example

string keyFile = "AlicePrivRSASign.p8e";    // Used to sign data
string password = "password";
// Input to be signed: a byte array with ASCII string "abc"
byte[] b = System.Text.Encoding.Default.GetBytes("abc");
string sig = Sig.SignData(b, keyFile, password, SigAlgorithm.Default);
Console.WriteLine("Sig.SignData returns \n'" + sig + "'");
/*
YK1aePtKQDDsVCyJdM0V9VOE6DZVTO3ZoyLV9BNcYmep0glwxU5mUQcLAUTUOETImTIN2
Pp4GffrxqdxUoczLshnXBNhg7P4ofge+WlBgmcTCnVv27LHHZpmdEbjTg6tnPMb+2b4Fv
MZ0LfkMKXyiRVTmG4ANyAmHH6QIsDZ8R8=*/

See Also

VB6/C equivalent: SIG_SignData

[Contents] [Index]

[PREV: Sig.GetHashAlgFromSigAlg Method...]   [Contents]   [Index]   
   [NEXT: Sig.SignDigest Method...]

Copyright © 2004-26 D.I. Management Services Pty Ltd t/a CryptoSys. All rights reserved. Generated 2026-09-17T11:18:15Z.