You are here

function encrypt_check_method in Encrypt 7

Same name and namespace in other branches
  1. 6 includes/encrypt.crypt.inc \encrypt_check_method()

Check Method

Check if a method is valid for encryption

Parameters

$method: Method to check for

Return value

Method name or FALSE

1 call to encrypt_check_method()
_encrypt_decrypt in includes/encrypt.crypt.inc
Private Encrypt and Decrypt

File

includes/encrypt.crypt.inc, line 234
This file holds the ffunctions necessary to encrypt and decrypt

Code

function encrypt_check_method($method = NULL) {
  $methods = encrypt_get_methods('full');
  $method = (string) $method;

  // Determine method
  if ($method == NULL) {
    $method = variable_get('encrypt_default_method', ENCRYPT_DEFAULT_METHOD);
  }

  // Make sure its a valid method
  if (!isset($methods[$method]) || !is_array($methods[$method])) {
    watchdog('encrypt', 'Encrypt call with invalid method: %method', array(
      '%method' => $method,
    ));
    return FALSE;
  }

  // Make sure theres a valid callback
  if (empty($methods[$method]['callback']) || !function_exists($methods[$method]['callback'])) {
    watchdog('encrypt', 'Encrypt function call is not valid: %function , for method: %method', array(
      '%method' => $method,
      '%function' => $methods[$method]['callback'],
    ));
    return FALSE;
  }
  return $method;
}