PGP

Frends.Pgp.EncryptFile / 2.1.0

Summary

Encrypts a file with a recipient's public key, optionally from a key ring, so only the holder of the matching private key can read it.

Typical use — outbound files containing anything sensitive, which keeps the payload protected independently of the transport

Details

Frends version
5.7 and newer
Agent
Crossplatform
Target framework
net8.0

Essential parameters.

Name Type Default Example Description
SourceFilePath String C:\temp\message.txt

Full path to the file for encryption.

OutputFilePath String C:\temp\message.pgp

Full path for the encrypted file.

OutputFileExistsAction OutputFileExistsAction OutputFileExistsAction.Overwrite

Action for if the output file exists.

Possible values:

  • Overwrite: Output file is overwritten if it exists.

  • Error: Exception is thrown if the output file already exists.

PublicKeySource PublicKeySource PublicKeySource.File

Source of the public key - file path or string.

Possible values:

  • File: Public key is read from a file.

  • String: Public key is provided directly as a string.

PublicKeyPath String C:\temp\publicKey.asc

Path to the public key file.

PublicKeyString String -----BEGIN PGP PUBLIC KEY BLOCK----- ... -----END PGP PUBLIC KEY BLOCK-----

Public key as a string, including the BEGIN/END PGP PUBLIC KEY BLOCK lines.

PublicKeyId String 0x1234567890ABCDEF 1234567890ABCDEF

ID of the correct key in the key ring (Optional). If left empty first suitable key in key ring is used.

EncryptionAlgorithm PgpEncryptEncryptionAlgorithm Cast5 PgpEncryptEncryptionAlgorithm.Cast5

Encryption algorithm to use

Possible values:

  • Aes128: AES with 128-bit key; secure and widely used.
  • Aes192: AES with 192-bit key; secure and widely used.
  • Aes256: AES with 256-bit key; secure and widely used, recommended for highest security.
  • Blowfish: Blowfish: symmetric cipher, moderately secure, older algorithm.
  • Camellia128: Camellia with 128-bit key; secure, alternative to AES.
  • Camellia192: Camellia with 192-bit key; secure, alternative to AES.
  • Camellia256: Camellia with 256-bit key; secure, alternative to AES.
  • Cast5: CAST5: older symmetric cipher, moderately secure.
  • Des: DES: outdated and insecure, provided only for legacy compatibility.
  • Idea: IDEA: older symmetric cipher, moderately secure, legacy use.
  • TripleDes: Triple DES (3DES): improves DES security, but slower and not recommended for new implementations.
  • Twofish: Twofish: symmetric cipher, secure, alternative to AES.
An unhandled error has occurred. Reload 🗙