function bakery_encrypt in Bakery Single Sign-On System 7.2
Same name and namespace in other branches
- 6.2 bakery.module \bakery_encrypt()
Encryption handler.
Parameters
string $text: The text to be encrypted.
Return value
string Encryped text.
1 call to bakery_encrypt()
- bakery_bake_data in ./
bakery.module - Encrypt and sign data for Bakery transfer.
File
- ./
bakery.module, line 1645 - Module file for the Bakery.
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;
}