Oihana Php Ftp

FtpCryptoTrait

Adds convenience helpers that combine FTP transfers with OpenSSL file encryption (reusing {@see OpenSSLFileEncryption} from `oihana/php-files`).

A local file is encrypted to a temporary file before upload, and a downloaded file is decrypted from a temporary file after transfer; the temporary file is always removed. Because the payload is ciphertext, these transfers are forced to binary mode.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Methods

downloadDecrypted()  : static
Downloads an encrypted remote file and decrypts it to the local filesystem.
uploadEncrypted()  : static
Encrypts a local file and uploads the ciphertext to the server.
temporaryCryptoFile()  : string
Creates a temporary file used to hold ciphertext during a secure transfer.

Methods

downloadDecrypted()

Downloads an encrypted remote file and decrypts it to the local filesystem.

public downloadDecrypted(string $remoteFile, string $localFile, string $passphrase) : static
Parameters
$remoteFile : string

The ciphertext source on the server.

$localFile : string

The plaintext destination on the local filesystem.

$passphrase : string

The passphrase used to derive the decryption key.

Tags
throws
FtpTransferException

When the transfer fails.

DirectoryException
FileException
Return values
static —

This instance, for chaining.

uploadEncrypted()

Encrypts a local file and uploads the ciphertext to the server.

public uploadEncrypted(string $localFile, string $remoteFile, string $passphrase) : static
Parameters
$localFile : string

The plaintext source on the local filesystem.

$remoteFile : string

The destination path on the server.

$passphrase : string

The passphrase used to derive the encryption key.

Tags
throws
DirectoryException
FileException
FtpTransferException

When the local file is missing, or the transfer fails.

Return values
static —

This instance, for chaining.

temporaryCryptoFile()

Creates a temporary file used to hold ciphertext during a secure transfer.

private temporaryCryptoFile() : string
Tags
throws
FtpTransferException

When the temporary file cannot be created.

Return values
string —

The temporary file path.

On this page

Search results