You are here

function bakery_encrypt in Bakery Single Sign-On System 6.2

Same name and namespace in other branches
  1. 7.2 bakery.module \bakery_encrypt()

Encryption handler.

Parameters

$text, The text to be encrypted.:

Return value

Encryped text.

1 call to bakery_encrypt()
bakery_bake_data in ./bakery.module
Encrypt and sign data for Bakery transfer.

File

./bakery.module, line 1527

Code

function bakery_encrypt($text) {
  $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);
  $data = mcrypt_generic($td, $text);
  mcrypt_generic_deinit($td);
  mcrypt_module_close($td);
  return $data;
}