You are here

function aes_load_phpsec in AES encryption 6

Same name and namespace in other branches
  1. 7 aes.module \aes_load_phpsec()
4 calls to aes_load_phpsec()
aes_config in ./aes.module
aes_decrypt in ./aes.module
aes_decrypt
aes_enable in ./aes.module
aes_encrypt in ./aes.module
aes_encrypt

File

./aes.module, line 43

Code

function aes_load_phpsec() {

  //find out where this module is located and set up an include path for the phpsec library
  $phpsec_include_path = dirname(__FILE__) . "/phpseclib";

  //include phpsec AES lib
  if (file_exists($phpsec_include_path . '/Crypt/AES.php') === false) {
    return -2;
  }
  else {
    if (is_readable($phpsec_include_path . '/Crypt/AES.php') === false) {
      drupal_set_message(t("It appears that phpseclib is installed in the right location but can't be read. Check that the permissions on the directory and its files allows for reading by the webserver."));
      return -3;
    }
    else {
      if (function_exists("set_include_path") == false) {

        //if we don't have set_include_path then we're out of luck
        return -1;
      }
      set_include_path(get_include_path() . PATH_SEPARATOR . $phpsec_include_path);
      include_once 'Crypt/AES.php';
      return true;
    }
  }
}