Reference > Functions reference > Container functions > CryptGenerateSignature
 

CryptGenerateSignature

Generates the digital signature of the data.

Format 

CryptGenerateSignature ( data ; algorithm ; privateRSAKey ; keyPassword )

Parameters 

data - any text expression to generate a signature from.

algorithm - the name of the cryptographic algorithm to use (see CryptAuthCode function).

privateRSAKey - text that represents an RSA private key. Optionally, the key may be encrypted.

keyPassword - the password to decrypt privateRSAKey with. If privateRSAKey is not encrypted, this parameter is ignored.

Data type returned 

container

Originated in version 

18.0

Description 

To generate a signature, this function first calculates the message digest of the data parameter using the specified algorithm. Then the digest is encrypted with the privateRSAKey parameter. If the private key is itself encrypted, you must provide the password as the last parameter, keyPassword.

An unencrypted RSA private key must be in this format:

-----BEGIN RSA PRIVATE KEY-----
MIIJKQIBAAKCAgEAqqDiwrPQwVaJzOzfFVBdhNjRNRxghZVQ9a3S88so8piw0uRt
...
A4jh5ffbGA6rlv1kEt1Inq2XDnKASjnWQGltDWWTJFs/XBcfoFXHpYiVINmp
-----END RSA PRIVATE KEY-----

An encrypted RSA private key must be in this format:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,B2EFE673714F681D

gMvo1cn1+Sjch4cPXT/Mty0pILnsbM5SsBPadRJJQtrGrM8LkkrRNdxYRBeIGUMj
...
lHGJJBHogUW4Ig3/kd4ROVHusRYLtyyfz13A96tIl6Y7lu2L7alNWQ==
-----END RSA PRIVATE KEY-----

To generate an RSA key pair, you can use the OpenSSL toolkit. See www.openssl.org.

This function returns a binary signature of data as container data, or it returns "?" if any of the parameters are invalid. You can convert the container data into text using the Base64EncodeRFC function or HexEncode function.

Example 1 

Uses the SHA-512 algorithm with an encrypted private key to sign the data in the Table::TextToSign text field. The signature is returned as Base64-encoded text.

Base64EncodeRFC ( 4648 ;
CryptGenerateSignature (
Table::TextToSign ; "SHA512" ; Table::PrivateRSAKey ; $Password
)
)

Related topics 

CryptVerifySignature function

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas