Back to the Function Reference Table of Contents

Encryption Functions

"Encryption" includes all forms of PGP encoding: key encryption, conventional encryption, and signing. For detached signatures, see the Signature Functions.

spgpEncode

Encrypt and/or sign text using conventional or public-key encryption.

Visual Basic declaration:

Declare Function spgp_encode Lib "spgp.dll" (
        ByVal BufferIn As String, 
        ByVal BufferOut As String, 
        ByVal BufferOutLen As Long, 
        ByVal Encrypt As Long, 
        ByVal Sign As Long, 
        ByVal SignAlg As Long, 
        ByVal Conventional As Long, 
        ByVal ConventionalAlg As Long, 
        ByVal Armor As Long, 
        ByVal TextMode As Long, 
        ByVal Clear As Long, 
        ByVal Compress As Long, 
        ByVal EyesOnly As Long, 
        ByVal MIME As Long,
        ByVal CryptKeyID As String, 
        ByVal SignKeyID As String, 
        ByVal SignKeyPass As String, 
        ByVal ConventionalPass As String, 
        ByVal Comment As String, 
        ByVal MIMESeparator As String
        ) As Long

Parameters:
BufferIn A fixed-length string which will act as a buffer for input.
BufferOut A fixed-length string which will act as a buffer for output.
BufferOutLen Size of BufferOut. If output exceeds BufferOutLen the output will be discarded and the function will return a positive number indicating the size of the output (i.e. the buffer size necessary to hold it).
KeyEncrypt Encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be key-encrypted using the public key indicated in CryptKeyID.
Equivalent to the '-e' command-line option in PGP 2.6.x.
Sign Sign? May be 0 (false) or 1 (true). If true, data in BufferIn will be digitally signed using the private key indicated in SignKeyID. The signing key's passphrase must be provided in SignKeyPass.
Equivalent to the '-s' command-line option in PGP 2.6.x.
SignAlg Hashing algorithm for a digital signature. For RSA keys only, SignAlg may be any one of the following:
"0" or the constant PGPHashAlgorithm_Default
"1" or the constant PGPHashAlgorithm_MD5
"2" or the constant PGPHashAlgorithm_SHA
"3" or the constant PGPHashAlgorithm_RIPEMD160
"4" or the constant PGPHashAlgorithm_SHADouble
A value of "0" indicates that the default algorithm for the signing key should be used. For RSA keys this is MD5, for all others it is SHA. DH/DSS (ElGamal) keys sign with SHA only. For such keys, a value other than "0" has no effect.
SHADouble is not available in PGP version 6.x.
ConventionalEncrypt Conventionally encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be conventionally encrypted using the algorithm indicated in ConventionalAlg and the passphrase indicated in ConventionalPass.
Equivalent to the '-c' command-line option in PGP 2.6.x.
ConventionalAlg Ciphering algorithm for conventional encryption. May be any one of the following:
"1" or the constant PGPCipherAlgorithm_IDEA
"2" or the constant PGPCipherAlgorithm_3DES
"3" or the constant PGPCipherAlgorithm_CAST5
The IDEA algorithm will be used by default.
Armor ASCII-armor output? May be 0 (false) or 1 (true). If true, output will be in "ASCII Radix-64 format suitable for transporting through E-mail channels" (a.k.a. "transport armor").
Equivalent to the '-a' or +armor=on command-line options in PGP 2.6.x.
TextMode Treat input as text? May be 0 (false) or 1 (true). If true, data in BufferIn will be converted to "canonical text" (CRLF at the end of each line) before encryption/signing.
Equivalent to the '-t' or '+textmode=on' command-line options in PGP 2.6.x.
Clear Clearsign? May be 0 (false) or 1 (true). If true, digitally signed data in BufferOut will be human-readable text instead of binary data. If Clear is true, Armor and TextMode will also be switched to true.
Equivalent to the '+clearsig=on' command-line option in PGP 2.6.x.
Compress Compression? May be 0 (false) or 1 (true). If true, plain text will be compressed before encryption.
EyesOnly FYEO Encryption? May be 0 (false) or 1 (true). If true, ciphertext will be flagged "For Your Eyes Only", which alerts decrypting clients to the fact that the resultant plain text should not be saved to disk, or otherwise made available to other recipients.
Equivalent to the '-m' command-line option in PGP 2.6.x.
MIME MIME Format? May be 0 (false) or 1 (true). If true, output will be in PGP/MIME format and the MIMESeparator parameter will contain the characters used to separate the MIME body parts. If MIME is true, the output will be ASCII-armored (Armor = true).
CryptKeyID Recipient's public key ID, which can be either the e-mail address from the key's user-ID or the ID number of the key itself, which must be prefixed by "0x".
SignKeyID Sender's private key ID, which can be either the e-mail address from the key's user-ID or the ID number of the key itself, which must be prefixed by "0x".
Equivalent to the '-u' command-line option in PGP 2.6.x.
SignKeyPass Passphrase to access sender's private key.
Equivalent to the '-z' command-line option in PGP 2.6.x.
ConventionalPass Passphrase for conventional encryption.
Comment Comment string. This will be added below the "Version:" string in digitally signed text. It will not appear on encrypted text unless the text is also signed. If this is blank ("") there will be no Comment.
MIMESeparator PGP/MIME Separator. When MIME has been set to true and the function has returned, this parameter will contain the string used by PGP to delineate the PGP/MIME body parts. The developer does not specify the separator. The maximum size of this string is 80 characters.

Notes and Warnings:

up to the top

spgpEncodeFile

Encrypt and/or sign a file using conventional or public-key encryption.

Visual Basic declaration:

Declare Function spgp_encodefile Lib "spgp.dll" (
	ByVal FileIn As String, 
	ByVal FileOut As String, 
	ByVal KeyEncrypt As Long, 
	ByVal Sign As Long, 
	ByVal SignAlg As Long,
	ByVal ConventionalEncrypt As Long, 
	ByVal ConventionalAlg As Long,
	ByVal Armor As Long, 
	ByVal TextMode As Long, 
	ByVal Clear As Long, 
	ByVal Compress As Long, 
	ByVal EyesOnly As Long, 
	ByVal MIME As Long,
	ByVal CryptKeyID As String, 
	ByVal SignKeyID As String, 
	ByVal SignKeyPass As String, 
	ByVal ConventionalPass As String,
	ByVal Comment As String,
	ByVal MIMESeparator as String
	) As Long

Parameters:
FileIn Input file. This must be a complete path and file name.
FileOut Output file. This must be a complete path and file name.
KeyEncrypt Encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be key-encrypted using the public key indicated in CryptKeyID.
Equivalent to the '-e' command-line option in PGP 2.6.x.
Sign Sign? May be 0 (false) or 1 (true). If true, data in BufferIn will be digitally signed using the private key indicated in SignKeyID. The signing key's passphrase must be provided in SignKeyPass.
Equivalent to the '-s' command-line option in PGP 2.6.x.
SignAlg Hashing algorithm for a digital signature. For RSA keys only, SignAlg may be any one of the following:
"0" or the constant PGPHashAlgorithm_Default
"1" or the constant PGPHashAlgorithm_MD5
"2" or the constant PGPHashAlgorithm_SHA
"3" or the constant PGPHashAlgorithm_RIPEMD160
"4" or the constant PGPHashAlgorithm_SHADouble
A value of "0" indicates that the default algorithm for the signing key should be used. For RSA keys this is MD5, for all others it is SHA. DH/DSS (ElGamal) keys sign with SHA only. For such keys, a value other than "0" has no effect.
SHADouble is not available in PGP version 6.x.
ConventionalEncrypt Conventionally encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be conventionally encrypted using the algorithm indicated in ConventionalAlg and the passphrase indicated in ConventionalPass.
Equivalent to the '-c' command-line option in PGP 2.6.x.
ConventionalAlg Ciphering algorithm for conventional encryption. May be any one of the following:
"1" or the constant PGPCipherAlgorithm_IDEA
"2" or the constant PGPCipherAlgorithm_3DES
"3" or the constant PGPCipherAlgorithm_CAST5
The IDEA algorithm will be used by default.
Armor ASCII-armor output? May be 0 (false) or 1 (true). If true, output will be in "ASCII Radix-64 format suitable for transporting through E-mail channels" (a.k.a. "transport armor").
Equivalent to the '-a' or +armor=on command-line options in PGP 2.6.x.
TextMode Treat input as text? May be 0 (false) or 1 (true). If true, data in BufferIn will be converted to "canonical text" (CRLF at the end of each line) before encryption/signing.
Equivalent to the '-t' or '+textmode=on' command-line options in PGP 2.6.x.
Clear Clearsign? May be 0 (false) or 1 (true). If true, digitally signed data in BufferOut will be human-readable text instead of binary data. If Clear is true, Armor and TextMode will also be switched to true.
Equivalent to the '+clearsig=on' command-line option in PGP 2.6.x.
Compress Compression? May be 0 (false) or 1 (true). If true, plain text will be compressed before encryption.
EyesOnly FYEO Encryption? May be 0 (false) or 1 (true). If true, ciphertext will be flagged "For Your Eyes Only", which alerts decrypting clients to the fact that the resultant plain text should not be saved to disk, or otherwise made available to other recipients.
Equivalent to the '-m' command-line option in PGP 2.6.x.
MIME MIME Format? May be 0 (false) or 1 (true). If true, output will be in PGP/MIME format and the MIMESeparator parameter will contain the characters used to separate the MIME body parts. If MIME is true, the output will be ASCII-armored (Armor = true).
CryptKeyID Recipient's public key ID, which can be either the e-mail address from the key's user-ID or the ID number of the key itself, which must be prefixed by "0x".
SignKeyID Sender's private key ID, which can be either the e-mail address from the key's user-ID or the ID number of the key itself, which must be prefixed by "0x".
Equivalent to the '-u' command-line option in PGP 2.6.x.
SignKeyPass Passphrase to access sender's private key.
Equivalent to the '-z' command-line option in PGP 2.6.x.
ConventionalPass Passphrase for conventional encryption.
Comment Comment string. This will be added below the "Version:" string in digitally signed text. It will not appear on encrypted text unless the text is also signed. If this is blank ("") there will be no Comment.
MIMESeparator PGP/MIME Separator. When MIME has been set to true and the function has returned, this parameter will contain the string used by PGP to delineate the PGP/MIME body parts. The developer does not specify the separator. The maximum size of this string is 80 characters.

Notes and Warnings:

up to the top

spgpUIEncode (PGP 6.x only)

Encrypt and/or sign text using conventional or public-key encryption. This is an alternative to spgpEncode which uses PGP's user-interface dialogs in place of parameters to specify keys and passphrases. The user is prompted to provide information about recipients, signing key, and passphrases for signing and conventional encryption.

Visual Basic declaration:

Declare Function spgpuiencode Lib "spgp.dll" (
        ByVal BufferIn As String, 
        ByVal BufferOut As String, 
        ByVal BufferOutLen As Long, 
        ByVal Encrypt As Long, 
        ByVal Sign As Long, 
        ByVal SignAlg As Long, 
        ByVal Conventional As Long, 
        ByVal ConventionalAlg As Long, 
        ByVal Clear As Long, 
        ByVal Compress As Long, 
        ByVal EyesOnly As Long, 
        ByVal MIME As Long, 
        ByVal Comment As String, 
        ByVal MIMESeparator As String, 
        ByVal WindowHandle As Long
        ) As Long

Parameters:
BufferIn A fixed-length string which will act as a buffer for input.
BufferOut A fixed-length string which will act as a buffer for output.
BufferOutLen Size of BufferOut. If output exceeds BufferOutLen the output will be discarded and the function will return a positive number indicating the size of the output (i.e. the buffer size necessary to hold it).
KeyEncrypt Encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be key-encrypted using the public key selected by the user via PGP's Recipients Dialog.
Equivalent to the '-e' command-line option in PGP 2.6.x.
Sign Sign? May be 0 (false) or 1 (true). If true, data in BufferIn will be digitally signed using the private key indicated by the user via PGP's Signing Passphrase Dialog.
Equivalent to the '-s' command-line option in PGP 2.6.x.
SignAlg Hashing algorithm for a digital signature. For RSA keys only, SignAlg may be any one of the following:
"0" or the constant PGPHashAlgorithm_Default
"1" or the constant PGPHashAlgorithm_MD5
"2" or the constant PGPHashAlgorithm_SHA
"3" or the constant PGPHashAlgorithm_RIPEMD160
"4" or the constant PGPHashAlgorithm_SHADouble
A value of "0" indicates that the default algorithm for the signing key should be used. For RSA keys this is MD5, for all others it is SHA. DH/DSS (ElGamal) keys sign with SHA only. For such keys, a value other than "0" has no effect.
SHADouble is not available in PGP version 6.x.
ConventionalEncrypt Conventionally encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be conventionally encrypted using the algorithm indicated in ConventionalAlg and the passphrase indicated by the user via PGP's Passphrase Dialog.
Equivalent to the '-c' command-line option in PGP 2.6.x.
ConventionalAlg Ciphering algorithm for conventional encryption. May be any one of the following:
"1" or the constant PGPCipherAlgorithm_IDEA
"2" or the constant PGPCipherAlgorithm_3DES
"3" or the constant PGPCipherAlgorithm_CAST5
The IDEA algorithm will be used by default.
Clear Clearsign? May be 0 (false) or 1 (true). If true, digitally signed data in BufferOut will be human-readable text instead of binary data. If Clear is true, Armor and TextMode will also be switched to true.
Equivalent to the '+clearsig=on' command-line option in PGP 2.6.x.
Compress Compression? May be 0 (false) or 1 (true). If true, plain text will be compressed before encryption.
EyesOnly FYEO Encryption? May be 0 (false) or 1 (true). If true, ciphertext will be flagged "For Your Eyes Only", which alerts decrypting clients to the fact that the resultant plain text should not be saved to disk, or otherwise made available to other recipients.
Equivalent to the '-m' command-line option in PGP 2.6.x.
MIME MIME Encoding? May be 0 (false) or 1 (true). If true, output will be in PGP/MIME format and the MIMESeparator parameter will contain the characters used to separate the MIME body parts. If MIME is true, the output will be ASCII-armored (Armor = true).
Comment Comment string. This will be added below the "Version:" string in digitally signed text. It will not appear on encrypted text unless the text is also signed. If this is blank ("") there will be no Comment.
MIMESeparator PGP/MIME Separator. When MIME has been set to true and the function has returned, this parameter will contain the string used by PGP to delineate the PGP/MIME body parts. The developer does not specify the separator. The maximum size of this string is 80 characters.
WindowHandle Handle (i.e., Hwnd) to the calling application or window. Passing this handle to the function makes any resulting dialog-boxes "children" of the calling application. Set this parameter to '0' avoid this effect.

Notes and Warnings:

up to the top

spgpUIEncodeFile (PGP 6.x only)

Encrypt and/or sign a file using conventional or public-key encryption. This is an alternative to spgpEncodeFile which uses PGP's user-interface dialogs in place of parameters to specify keys and passphrases. The user is prompted to provide information about recipients, signing key, and passphrases for signing and conventional encryption.

Visual Basic declaration:

Declare Function spgpuiencodefile Lib "spgp.dll" (
	      ByVal FileIn As String, 
	      ByVal FileOut As String, 
	      ByVal Encrypt As Long, 
	      ByVal Sign As Long, 
	      ByVal SignAlg As Long, 
	      ByVal ConventionalEncrypt As Long, 
	      ByVal ConventionalAlg As Long, 
	      ByVal Armor As Long, 
	      ByVal TextMode As Long, 
	      ByVal Clear As Long, 
	      ByVal Compress As Long, 
	      ByVal EyesOnly As Long, 
	      ByVal MIME As Long, 
	      ByVal Comment As String, 
	      ByVal MIMESeparator As String, 
	      ByVal AppHandle As Long
	) As Long

Parameters:
FileIn Input file. This must be a complete path and file name.
FileOut Output file. This must be a complete path and file name.
KeyEncrypt Encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be key-encrypted using the public key indicated by the user via PGP's Recipients Dialog.
Equivalent to the '-e' command-line option in PGP 2.6.x.
Sign Sign? May be 0 (false) or 1 (true). If true, data in BufferIn will be digitally signed using the private key indicated by the user via PGP's Signing Passphrase Dialog.
Equivalent to the '-s' command-line option in PGP 2.6.x.
SignAlg Hashing algorithm for a digital signature. For RSA keys only, SignAlg may be any one of the following:
"0" or the constant PGPHashAlgorithm_Default
"1" or the constant PGPHashAlgorithm_MD5
"2" or the constant PGPHashAlgorithm_SHA
"3" or the constant PGPHashAlgorithm_RIPEMD160
"4" or the constant PGPHashAlgorithm_SHADouble
A value of "0" indicates that the default algorithm for the signing key should be used. For RSA keys this is MD5, for all others it is SHA. DH/DSS (ElGamal) keys sign with SHA only. For such keys, a value other than "0" has no effect.
SHADouble is not available in PGP version 6.x.
ConventionalEncrypt Conventionally encrypt? May be 0 (false) or 1 (true). If true, data in BufferIn will be conventionally encrypted using the algorithm indicated in ConventionalAlg and the passphrase indicated by the user in PGP's Passphrase Dialog.
Equivalent to the '-c' command-line option in PGP 2.6.x.
ConventionalAlg Ciphering algorithm for conventional encryption. May be any one of the following:
"1" or the constant PGPCipherAlgorithm_IDEA
"2" or the constant PGPCipherAlgorithm_3DES
"3" or the constant PGPCipherAlgorithm_CAST5
The IDEA algorithm will be used by default.
Armor ASCII-armor output? May be 0 (false) or 1 (true). If true, output will be in "ASCII Radix-64 format suitable for transporting through E-mail channels" (a.k.a. "transport armor").
Equivalent to the '-a' or +armor=on command-line options in PGP 2.6.x.
TextMode Treat input as text? May be 0 (false) or 1 (true). If true, data in BufferIn will be converted to "canonical text" (CRLF at the end of each line) before encryption/signing.
Equivalent to the '-t' or '+textmode=on' command-line options in PGP 2.6.x.
Clear Clearsign? May be 0 (false) or 1 (true). If true, digitally signed data in BufferOut will be human-readable text instead of binary data. If Clear is true, Armor and TextMode will also be switched to true.
Equivalent to the '+clearsig=on' command-line option in PGP 2.6.x.
Compress Compression? May be 0 (false) or 1 (true). If true, plain text will be compressed before encryption.
EyesOnly FYEO Encryption? May be 0 (false) or 1 (true). If true, ciphertext will be flagged "For Your Eyes Only", which alerts decrypting clients to the fact that the resultant plain text should not be saved to disk, or otherwise made available to other recipients.
Equivalent to the '-m' command-line option in PGP 2.6.x.
MIME MIME Encoding? May be 0 (false) or 1 (true). If true, output will be in PGP/MIME format and the MIMESeparator parameter will contain the characters used to separate the MIME body parts. If MIME is true, the output will be ASCII-armored (Armor = true).
Comment Comment string. This will be added below the "Version:" string in digitally signed text. It will not appear on encrypted text unless the text is also signed. If this is blank ("") there will be no Comment.
MIMESeparator PGP/MIME Separator. When MIME has been set to true and the function has returned, this parameter will contain the string used by PGP to delineate the PGP/MIME body parts. The developer does not specify the separator. The maximum size of this string is 80 characters.

Notes and Warnings:

up to the top
Back to the Function Reference Table of Contents