/**
  * @param ASSLEncryption $enc
  * @param string $status
  * @return array
  */
 private function _load_keys($enc, $status = '')
 {
     //get key files from the directory
     $files = array_filter(glob($enc->getKeyPath() . '/*'), function ($file) {
         return preg_match('/.pub$/', $file);
     });
     $pub_keys = array_map(function ($file) {
         return basename($file, ".pub");
     }, $files);
     //load active keys from db
     $status_sql = '';
     if ($status) {
         $status_sql = " WHERE `status` = " . (int) $status;
     }
     $query = $this->db->query("SELECT * FROM " . $this->db->table('encryption_keys') . $status_sql);
     return $query->rows;
 }
 /**
  * Decrypt 1 field of data
  * @param string $crypt_data
  * @param int $key_id
  * @param null|string $pass
  * @return string
  */
 public function decrypt_field($crypt_data, $key_id = 0, $pass = null)
 {
     if (empty($pass)) {
         $pass = $this->passphrase;
     }
     //if encryption off return pure data
     if (!$this->active) {
         return $crypt_data;
     }
     //detect key to use
     $key_name = $this->_detect_decrypt_key($key_id);
     $enc = new ASSLEncryption('', $key_name, $pass);
     return $enc->decrypt($crypt_data);
 }