function _ldap_servers_decrypt in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.encryption.inc \_ldap_servers_decrypt()
- 7.2 ldap_servers/ldap_servers.encryption.inc \_ldap_servers_decrypt()
Encrypt Decrypt Method
Parameters
string $cipher_txt: ciphered text.
Return value
string clear text
http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypt...
1 call to _ldap_servers_decrypt()
- ldap_servers_decrypt in ldap_servers/
ldap_servers.module
File
- ldap_servers/
ldap_servers.encryption.inc, line 132 - Provides functions for encryption/decryption. http://stackoverflow.com/questions/2448256/php-mcrypt-encrypting-decrypt...
Code
function _ldap_servers_decrypt($cipher_txt, $enc_type = NULL) {
$key = variable_get('ldap_servers_encrypt_key', NULL);
if (!$enc_type) {
$enc_type = variable_get('ldap_servers_encryption', LDAP_SERVERS_ENC_TYPE_CLEARTEXT);
}
if ($enc_type == LDAP_SERVERS_ENC_TYPE_CLEARTEXT) {
return $cipher_txt;
}
$cipher_txt = base64_decode($cipher_txt);
switch ($enc_type) {
case LDAP_SERVERS_ENC_TYPE_BLOWFISH:
// Blowfish
$clear_txt = "";
$td = mcrypt_module_open('blowfish', '', LDAP_SERVERS_CYPHER_MODE, '');
$ivsize = mcrypt_enc_get_iv_size($td);
$iv = substr($cipher_txt, 0, $ivsize);
$cipher_txt = substr($cipher_txt, $ivsize);
if ($iv) {
mcrypt_generic_init($td, $key, $iv);
$clear_txt = mdecrypt_generic($td, $cipher_txt);
}
break;
default:
// Cleartext
$clear_txt = $cipher_txt;
}
return $clear_txt;
}