You are here

private function BaseMethod::cryptFileExecute in DRD Agent 8.3

Same name and namespace in other branches
  1. 4.0.x src/Crypt/BaseMethod.php \Drupal\drd_agent\Crypt\BaseMethod::cryptFileExecute()

Callback to encrypt and decrypt files.

Parameters

string $mode: This is "-e" to encrypt or "-d" to decrypt.

string $in: Input filename.

string $out: Output filename.

Return value

int Exit code of the openssl command.

1 call to BaseMethod::cryptFileExecute()
BaseMethod::encryptFile in src/Crypt/BaseMethod.php
Encrypt a file.

File

src/Crypt/BaseMethod.php, line 49

Class

BaseMethod
Provides base encryption method.

Namespace

Drupal\drd_agent\Crypt

Code

private function cryptFileExecute($mode, $in, $out) : int {
  $output = [];
  $cmd = [
    'openssl',
    $this
      ->getCipher(),
    $mode,
    '-a',
    '-salt',
    '-in',
    $in,
    '-out',
    $out,
    '-k',
    base64_encode($this
      ->getPassword()),
  ];
  exec(implode(' ', $cmd), $output, $ret);
  return $ret;
}