Takes two resource handles and decrypts the contents of the first,
writing the plaintext into the second.
public static decryptResource ( resource $inputHandle, resource $outputHandle, Defuse\Crypto\Key $key ) | ||
$inputHandle | resource | |
$outputHandle | resource | |
$key | Defuse\Crypto\Key |
/** * Decrypts a stream. * * @param resource $resource The stream to decrypt. * * @return resource The decrypted stream. */ private function decryptStream($resource) { $out = fopen('php://memory', 'r+b'); File::decryptResource($resource, $out, $this->key()); rewind($out); return $out; }
/** * Decrypts a string. * * @param string $contents The string to decrypt. * * @return string The decrypted string. */ protected function decrypt($contents) { $resource = fopen('php://memory', 'r+b'); File::writeBytes($resource, $contents); rewind($resource); $out = fopen('php://memory', 'r+b'); File::decryptResource($resource, $out, $this->key); rewind($out); return stream_get_contents($out); }