public function decrypt($item) { $value = $this->trim(des($this->_desKey, hex2bin($item), 0, 0, 1)); if ($value) { return $value; } return false; }
private function encodeEmail($matches) { if ($this->mode == 'native') { $iv_size = mcrypt_get_iv_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_CBC); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $str = $matches[1] . '@' . $matches[2]; $e = mcrypt_encrypt(MCRYPT_TRIPLEDES, $this->_em_key, $str, MCRYPT_MODE_CBC, $iv); return 'href="#send_email" rev="em_' . strlen($str) . '_' . substr(Utils::stringToHex($e), 2) . '_' . substr(Utils::stringToHex($iv), 2) . '" class="em_encrypted_native" '; } if ($this->mode == 'file') { $enc = substr(stringToHex(des($this->_em_key, $matches[1] . '@' . $matches[2], 1, 0, null)), 2); return 'href="#send_email" rev="em_' . $enc . '" class="em_encrypted_file" '; } }
function decrypt($key, $message) { return des($key, $message, 0, 0, null, 2); }
/** * Decrypt 3DES-encrypted string * * @param string $cipher encrypted text * @param string $key encryption key to retrieve from the configuration, defaults to 'des_key' * @param boolean $base64 whether or not input is base64-encoded * * @return string decrypted text */ public function decrypt($cipher, $key = 'des_key', $base64 = true) { if (!$cipher) { return ''; } $cipher = $base64 ? base64_decode($cipher) : $cipher; if (function_exists('mcrypt_module_open') && ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, ""))) { $iv_size = mcrypt_enc_get_iv_size($td); $iv = substr($cipher, 0, $iv_size); // session corruption? (#1485970) if (strlen($iv) < $iv_size) { return ''; } $cipher = substr($cipher, $iv_size); mcrypt_generic_init($td, $this->config->get_crypto_key($key), $iv); $clear = mdecrypt_generic($td, $cipher); mcrypt_generic_deinit($td); mcrypt_module_close($td); } else { @(include_once 'des.inc'); if (function_exists('des')) { $des_iv_size = 8; $iv = substr($cipher, 0, $des_iv_size); $cipher = substr($cipher, $des_iv_size); $clear = des($this->config->get_crypto_key($key), $cipher, 0, 1, $iv); } else { self::raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not perform decryption; make sure Mcrypt is installed or lib/des.inc is available"), true, true); } } /*- * Trim PHP's padding and the canary byte; see note in * rcube::encrypt() and http://php.net/mcrypt_generic#68082 */ $clear = substr(rtrim($clear, ""), 0, -1); return $clear; }
/** * Decrypt IMAP password using DES encryption * * @param string Encrypted password * @return string Plain password */ public function decrypt_passwd($cypher) { if (function_exists('mcrypt_module_open') && ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_ECB, ""))) { $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); mcrypt_generic_init($td, $this->config->get_des_key(), $iv); $pass = mdecrypt_generic($td, base64_decode($cypher)); mcrypt_generic_deinit($td); mcrypt_module_close($td); } else { if (function_exists('des')) { $pass = des($this->config->get_des_key(), base64_decode($cypher), 0, 0, NULL); } else { $pass = base64_decode($cypher); } } return preg_replace('/\\x00/', '', $pass); }
function decrypt_passwd($cypher) { global $config; $pass = des($config['des_key'], base64_decode($cypher), 0, 0, NULL); return preg_replace('/\\x00/', '', $pass); }
function passwd_undes($role, $user, $hash) { if ($role == 2) { // adminpass global $adminpass; list($scheme, $key) = auth::passwd_parse($adminpass); } else { $obj = new auth_file(PKWK_AUTH_FILE); list($o_scheme, $key, $o_role) = $obj->get_data($user); } $hash = des($key, base64_decode($hash), 0, 0, null); if (!preg_match('/^[a-z0-9]+$/iD', $hash)) { return false; } return $hash; }
function des_session_put($session_name, $val) { global $adminpass; // adminpass の処理 list($scheme, $salt) = auth::passwd_parse($adminpass); require_once LIB_DIR . 'des.php'; $_SESSION[$session_name] = base64_encode(des($salt, $val, 1, 0, null)); }
function htdigest_save($username, $p_realm, $hash, $role) { global $realm, $_htdigest_msg; if ($realm != $p_realm) { return $_htdigest_msg['msg_realm']; } // DES if ($role > 2) { $key = htdigest_get_hash($username, $p_realm); } else { // adminpass global $adminpass; list($scheme, $key) = auth::passwd_parse($adminpass); // FIXME: MD5 ONLY if ($scheme != '{x-php-md5}') { return $_htdigest_msg['err_md5']; } } $hash = des($key, base64_decode($hash), 0, 0, null); if (!preg_match('/^[a-z0-9]+$/iD', $hash)) { return $_htdigest_msg['err_key']; } // SAVE if (file_exists(HTDIGEST_FILE)) { $lines = file(HTDIGEST_FILE); } else { $fp = fopen(HTDIGEST_FILE, 'w'); @flock($fp, LOCK_EX); fputs($fp, $username . ':' . $realm . ':' . $hash . "\n"); @flock($fp, LOCK_UN); @fclose($fp); return $_htdigest_msg['msg_1st']; } $sw = FALSE; foreach ($lines as $no => $line) { $field = split(':', trim($line)); if ($field[0] == $username && $field[1] == $p_realm) { if ($field[2] == $hash) { return $_htdigest_msg['msg_not_update']; } $sw = TRUE; $lines[$no] = $field[0] . ':' . $field[1] . ':' . $hash . "\n"; break; } } if (!$sw) { $fp = fopen(HTDIGEST_FILE, 'a'); @flock($fp, LOCK_EX); fputs($fp, $username . ':' . $p_realm . ':' . $hash . "\n"); @flock($fp, LOCK_UN); @fclose($fp); return $_htdigest_msg['msg_add']; } $fp = fopen(HTDIGEST_FILE, 'w'); @flock($fp, LOCK_EX); foreach ($lines as $line) { fwrite($fp, $line); } @flock($fp, LOCK_UN); @fclose($fp); return $_htdigest_msg['msg_update']; }
<div> <u>Voici vos résultats : </u><br><br> <?php des($aventurier->COU - 7); ?> <?php des($aventurier->INT - 7); ?> <?php des($aventurier->CHA - 7); ?> <?php des($aventurier->AD - 7); ?> <?php des($aventurier->FO - 7); ?> </div> <div style='margin-top:70px;'> <u>Ce qui vous donne comme caractéristiques :</u><br /> <table> <tr><td>Courage <?php getValeurCaracM($aventurier->COU); ?> : </td><td> <?php echo $aventurier->COU; ?> </td></tr> <tr><td>Intelligence <?php
/** * Decrypt 3DES-encrypted string * * @param string $cipher Encrypted text * @param string $key Encryption key to retrieve from the configuration, defaults to 'des_key' * @param boolean $base64 Whether or not input is base64-encoded * * @return string decrypted text */ public function decrypt($cipher, $key = 'des_key', $base64 = true) { if (!$cipher) { return ''; } $cipher = $base64 ? base64_decode($cipher) : $cipher; $ckey = $this->config->get_crypto_key($key); if (function_exists('openssl_decrypt')) { $method = 'DES-EDE3-CBC'; $opts = defined('OPENSSL_RAW_DATA') ? OPENSSL_RAW_DATA : true; $iv_size = openssl_cipher_iv_length($method); $iv = substr($cipher, 0, $iv_size); // session corruption? (#1485970) if (strlen($iv) < $iv_size) { return ''; } $cipher = substr($cipher, $iv_size); $clear = openssl_decrypt($cipher, $method, $ckey, $opts, $iv); } else { if (function_exists('mcrypt_module_open') && ($td = mcrypt_module_open(MCRYPT_TripleDES, "", MCRYPT_MODE_CBC, ""))) { $iv_size = mcrypt_enc_get_iv_size($td); $iv = substr($cipher, 0, $iv_size); // session corruption? (#1485970) if (strlen($iv) < $iv_size) { return ''; } $cipher = substr($cipher, $iv_size); mcrypt_generic_init($td, $ckey, $iv); $clear = mdecrypt_generic($td, $cipher); mcrypt_generic_deinit($td); mcrypt_module_close($td); } else { @(include_once 'des.inc'); if (function_exists('des')) { $des_iv_size = 8; $iv = substr($cipher, 0, $des_iv_size); $cipher = substr($cipher, $des_iv_size); $clear = des($ckey, $cipher, 0, 1, $iv); } else { self::raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Could not perform decryption; make sure OpenSSL or Mcrypt or lib/des.inc is available"), true, true); } } } // Trim PHP's padding and the canary byte; see note in // rcube::encrypt() and http://php.net/mcrypt_generic#68082 $clear = substr(rtrim($clear, ""), 0, -1); return $clear; }