ffi = FFI::cdef($code, "libcrypto.so"); } public function init() { $this->load(); $ffi = $this->getFFI(); $ffi->ERR_load_crypto_strings(); $ffi->OPENSSL_add_all_algorithms_conf(); $ffi->OPENSSL_config(null); } public function __destruct() { if ($this->ffi === null) { return; } $this->ffi->EVP_cleanup(); $this->ffi->CRYPTO_cleanup_all_ex_data(); $this->ffi->ERR_free_strings(); } public function getFFI(): FFI { if ($this->ffi === null) { throw new \RuntimeException("Failed to load FFI"); } return $this->ffi; } }