/** * Returns a stream representation of a string. * * @param string $contents The string * * @return resource The stream with the string contents. */ private function getStreamFromString($contents) { $resource = fopen('php://memory', 'r+b'); File::writeBytes($resource, $contents); rewind($resource); return $resource; }
/** * Encrypts a string. * * @param string $contents The string to encrypt. * * @return string The encrypted string. */ protected function encrypt($contents) { $resource = fopen('php://memory', 'r+b'); File::writeBytes($resource, $contents); rewind($resource); $out = fopen('php://memory', 'r+b'); File::encryptResource($resource, $out, $this->key); rewind($out); return stream_get_contents($out); }