You are here

function bakery_mix in Bakery Single Sign-On System 6

Encryption

Parameters

$text, The text that you want to encrypt.:

$crypt = 1 if you want to crypt, or 0 if you want to decrypt.:

5 calls to bakery_mix()
bakery_bake_oatmeal_cookie in ./bakery.module
Create a new cookie for redirection after login
bakery_taste_stroopwafel_cookie in ./bakery.module
Validate update request.
bakery_user in ./bakery.module
Implementation of hook_user().
_bakery_bake_chocolatechip_cookie in ./bakery.module
Create a new cookie for identification
_bakery_validate_cookie in ./bakery.module
Function to validate cookies

File

./bakery.module, line 619

Code

function bakery_mix($text, $crypt) {
  $key = variable_get('bakery_key', '');
  $td = mcrypt_module_open('rijndael-128', '', 'ecb', '');
  $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
  $key = substr($key, 0, mcrypt_enc_get_key_size($td));
  mcrypt_generic_init($td, $key, $iv);
  if ($crypt) {
    $encrypted_data = mcrypt_generic($td, $text);
  }
  else {
    $encrypted_data = mdecrypt_generic($td, $text);
  }
  mcrypt_generic_deinit($td);
  mcrypt_module_close($td);
  return $encrypted_data;
}