API Reference
This page provides the complete API documentation for the RobotFrameworkPGP library.
RobotFrameworkPGP Class
- class RobotFrameworkPGP.pgp_library.RobotFrameworkPGP(gnupg_home=None)[source]
Bases:
objectRobot Framework library for PGP/GPG encryption and decryption operations.
This library provides keywords for: - Text and file encryption/decryption - Key generation and management - Digital signatures - GPG operations
= Table of contents =
Initialization
Configuration
Encryption and Decryption
Key Management
Digital Signatures
Utility Keywords
= Initialization =
The library can be imported with optional parameters:
Library | RobotFrameworkPGP |Library | RobotFrameworkPGP | gnupg_home=/path/to/gnupg |= Configuration =
Before using encryption/decryption operations, you need to configure the GPG environment.
= Examples =
Set GPG Home Directory | /tmp/gnupg |Generate Key Pair | test@example.com | Test User | 2048 |${encrypted} | Encrypt Text | Hello World | test@example.com |${decrypted} | Decrypt Text | ${encrypted} | passphrase=secret |- ROBOT_LIBRARY_SCOPE = 'GLOBAL'
- ROBOT_LIBRARY_VERSION = '1.0.0'
- ROBOT_LIBRARY_DOC_FORMAT = 'ROBOT'
- set_gpg_home_directory(gnupg_home)[source]
Set the GPG home directory.
Example
Set GPG Home Directory | /tmp/my_gnupg |
- generate_key_pair(email, name, key_length=2048, passphrase=None, expire_date='0')[source]
Generate a new GPG key pair.
- Parameters:
- Return type:
- Returns:
Key fingerprint of the generated key
Example
${fingerprint} | Generate Key Pair | test@example.com | Test User | 2048 | secret123 |
- import_key(key_data)[source]
Import a GPG key from key data.
- Parameters:
key_data (
str) – The key data to import (ASCII armored)- Return type:
- Returns:
List of imported key fingerprints
Example
${fingerprints} | Import Key | ${key_data} |
- import_key_from_file(key_file_path)[source]
Import a GPG key from a file.
- Parameters:
key_file_path (
str) – Path to the key file- Return type:
- Returns:
List of imported key fingerprints
Example
${fingerprints} | Import Key From File | /path/to/public.key |
- export_public_key(key_id)[source]
Export a public key.
- Parameters:
key_id (
str) – Key ID, fingerprint, or email address- Return type:
- Returns:
ASCII armored public key
Example
${public_key} | Export Public Key | test@example.com |
- export_private_key(key_id, passphrase=None)[source]
Export a private key.
- Parameters:
- Return type:
- Returns:
ASCII armored private key
Example
${private_key} | Export Private Key | test@example.com | secret123 |
- list_keys(secret=False)[source]
List GPG keys.
- Parameters:
secret (
bool) – If True, list secret keys; otherwise list public keys- Return type:
- Returns:
List of key information dictionaries
Example
${keys} | List Keys |${secret_keys} | List Keys | secret=${True} |
- encrypt_text(text, recipients, sign=None, passphrase=None, armor=True)[source]
Encrypt text for specified recipients.
- Parameters:
- Return type:
- Returns:
Encrypted text
Example
${encrypted} | Encrypt Text | Hello World | test@example.com |${encrypted} | Encrypt Text | Secret message | test@example.com | sign=signer@example.com | passphrase=secret |
- decrypt_text(encrypted_text, passphrase=None)[source]
Decrypt encrypted text.
- Parameters:
- Return type:
- Returns:
Decrypted text
Example
${decrypted} | Decrypt Text | ${encrypted_text} | passphrase=secret |
- encrypt_file(input_file, output_file, recipients, sign=None, passphrase=None, armor=True)[source]
Encrypt a file for specified recipients.
- Parameters:
- Return type:
Example
Encrypt File | input.txt | output.txt.gpg | test@example.com |
- decrypt_file(input_file, output_file, passphrase=None)[source]
Decrypt an encrypted file.
- Parameters:
- Return type:
Example
Decrypt File | input.txt.gpg | output.txt | passphrase=secret |
- sign_text(text, key_id, passphrase=None)[source]
Create a digital signature for text.
- Parameters:
- Return type:
- Returns:
Signed text (cleartext signature)
Example
${signed} | Sign Text | Hello World | test@example.com | passphrase=secret |
- verify_signature(signed_text)[source]
Verify a digital signature.
- Parameters:
signed_text (
str) – Signed text to verify- Return type:
- Returns:
Dictionary with verification results
Example
${result} | Verify Signature | ${signed_text} |Should Be True | ${result}[valid] |
- delete_key(key_id, secret=False, passphrase=None)[source]
Delete a GPG key.
- Parameters:
- Return type:
Example
Delete Key | test@example.com |Delete Key | test@example.com | secret=${True} | passphrase=secret |
- get_gpg_version()[source]
Get the GPG version information.
- Return type:
- Returns:
GPG version string
Example
${version} | Get GPG Version |
- get_key_info(key_id)[source]
Get detailed information about a specific key.
- Parameters:
key_id (
str) – Key ID, fingerprint, or email address- Return type:
- Returns:
Dictionary with key information
Example
${info} | Get Key Info | test@example.com |
- create_symmetric_encryption(text, passphrase)[source]
Create symmetric encryption (password-based).
- Parameters:
- Return type:
- Returns:
Encrypted text
Example
${encrypted} | Create Symmetric Encryption | Secret data | mypassword |
- ROBOT_AUTO_KEYWORDS = False
Module Contents
Robot Framework library for PGP/GPG encryption and decryption operations.
- class RobotFrameworkPGP.RobotFrameworkPGP(gnupg_home=None)[source]
Bases:
objectRobot Framework library for PGP/GPG encryption and decryption operations.
This library provides keywords for: - Text and file encryption/decryption - Key generation and management - Digital signatures - GPG operations
= Table of contents =
Initialization
Configuration
Encryption and Decryption
Key Management
Digital Signatures
Utility Keywords
= Initialization =
The library can be imported with optional parameters:
Library | RobotFrameworkPGP |Library | RobotFrameworkPGP | gnupg_home=/path/to/gnupg |= Configuration =
Before using encryption/decryption operations, you need to configure the GPG environment.
= Examples =
Set GPG Home Directory | /tmp/gnupg |Generate Key Pair | test@example.com | Test User | 2048 |${encrypted} | Encrypt Text | Hello World | test@example.com |${decrypted} | Decrypt Text | ${encrypted} | passphrase=secret |- ROBOT_LIBRARY_SCOPE = 'GLOBAL'
- ROBOT_LIBRARY_VERSION = '1.0.0'
- ROBOT_LIBRARY_DOC_FORMAT = 'ROBOT'
- set_gpg_home_directory(gnupg_home)[source]
Set the GPG home directory.
Example
Set GPG Home Directory | /tmp/my_gnupg |
- generate_key_pair(email, name, key_length=2048, passphrase=None, expire_date='0')[source]
Generate a new GPG key pair.
- Parameters:
- Return type:
- Returns:
Key fingerprint of the generated key
Example
${fingerprint} | Generate Key Pair | test@example.com | Test User | 2048 | secret123 |
- import_key(key_data)[source]
Import a GPG key from key data.
- Parameters:
key_data (
str) – The key data to import (ASCII armored)- Return type:
- Returns:
List of imported key fingerprints
Example
${fingerprints} | Import Key | ${key_data} |
- import_key_from_file(key_file_path)[source]
Import a GPG key from a file.
- Parameters:
key_file_path (
str) – Path to the key file- Return type:
- Returns:
List of imported key fingerprints
Example
${fingerprints} | Import Key From File | /path/to/public.key |
- export_public_key(key_id)[source]
Export a public key.
- Parameters:
key_id (
str) – Key ID, fingerprint, or email address- Return type:
- Returns:
ASCII armored public key
Example
${public_key} | Export Public Key | test@example.com |
- export_private_key(key_id, passphrase=None)[source]
Export a private key.
- Parameters:
- Return type:
- Returns:
ASCII armored private key
Example
${private_key} | Export Private Key | test@example.com | secret123 |
- list_keys(secret=False)[source]
List GPG keys.
- Parameters:
secret (
bool) – If True, list secret keys; otherwise list public keys- Return type:
- Returns:
List of key information dictionaries
Example
${keys} | List Keys |${secret_keys} | List Keys | secret=${True} |
- encrypt_text(text, recipients, sign=None, passphrase=None, armor=True)[source]
Encrypt text for specified recipients.
- Parameters:
- Return type:
- Returns:
Encrypted text
Example
${encrypted} | Encrypt Text | Hello World | test@example.com |${encrypted} | Encrypt Text | Secret message | test@example.com | sign=signer@example.com | passphrase=secret |
- decrypt_text(encrypted_text, passphrase=None)[source]
Decrypt encrypted text.
- Parameters:
- Return type:
- Returns:
Decrypted text
Example
${decrypted} | Decrypt Text | ${encrypted_text} | passphrase=secret |
- encrypt_file(input_file, output_file, recipients, sign=None, passphrase=None, armor=True)[source]
Encrypt a file for specified recipients.
- Parameters:
- Return type:
Example
Encrypt File | input.txt | output.txt.gpg | test@example.com |
- decrypt_file(input_file, output_file, passphrase=None)[source]
Decrypt an encrypted file.
- Parameters:
- Return type:
Example
Decrypt File | input.txt.gpg | output.txt | passphrase=secret |
- sign_text(text, key_id, passphrase=None)[source]
Create a digital signature for text.
- Parameters:
- Return type:
- Returns:
Signed text (cleartext signature)
Example
${signed} | Sign Text | Hello World | test@example.com | passphrase=secret |
- verify_signature(signed_text)[source]
Verify a digital signature.
- Parameters:
signed_text (
str) – Signed text to verify- Return type:
- Returns:
Dictionary with verification results
Example
${result} | Verify Signature | ${signed_text} |Should Be True | ${result}[valid] |
- delete_key(key_id, secret=False, passphrase=None)[source]
Delete a GPG key.
- Parameters:
- Return type:
Example
Delete Key | test@example.com |Delete Key | test@example.com | secret=${True} | passphrase=secret |
- get_gpg_version()[source]
Get the GPG version information.
- Return type:
- Returns:
GPG version string
Example
${version} | Get GPG Version |
- get_key_info(key_id)[source]
Get detailed information about a specific key.
- Parameters:
key_id (
str) – Key ID, fingerprint, or email address- Return type:
- Returns:
Dictionary with key information
Example
${info} | Get Key Info | test@example.com |
- create_symmetric_encryption(text, passphrase)[source]
Create symmetric encryption (password-based).
- Parameters:
- Return type:
- Returns:
Encrypted text
Example
${encrypted} | Create Symmetric Encryption | Secret data | mypassword |
- ROBOT_AUTO_KEYWORDS = False