本文整理汇总了PHP中Ak::decrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::decrypt方法的具体用法?PHP Ak::decrypt怎么用?PHP Ak::decrypt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::decrypt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Test_of_encrypt_decrypt
public function Test_of_encrypt_decrypt()
{
$original = "Este es el texto que quiero encriptar";
$this->assertEqual(Ak::decrypt(Ak::encrypt($original)), $original);
$key = Ak::randomString(20);
$file = file_get_contents(__FILE__);
$ecripted = Ak::encrypt($file, $key);
$this->assertEqual(Ak::decrypt($ecripted, $key), $file);
}
示例2: connect
function connect($base_dir = null)
{
static $ftp_conn, $_base_dir, $disconnected = false;
if (!isset($ftp_conn) || $disconnected) {
if (!defined('AK_FTP_PATH')) {
trigger_error(Ak::t('You must set a valid FTP connection on AK_FTP_PATH in your config/config.php file'), E_USER_ERROR);
} else {
if (AK_AUTOMATIC_CONFIG_VARS_ENCRYPTION && substr(AK_FTP_PATH, 0, 10) == 'PROTECTED:') {
// You should change the key bellow and encode this file if you are going to distribute applications
// The ideal protection would be to encode user configuration file.
$AK_FTP_PATH = Ak::decrypt(base64_decode(substr(AK_FTP_PATH, 10)), 'HR23JHR93JZ0ALi1UvTZ0ALi1UvTk7MD70');
$_pass_encoded = true;
} else {
$AK_FTP_PATH = AK_FTP_PATH;
}
$f = parse_url($AK_FTP_PATH);
if (@$f['scheme'] != 'ftps') {
$ftp_conn = isset($f['port']) ? ftp_connect($f['host'], $f['port']) : ftp_connect($f['host']);
} else {
$ftp_conn = isset($f['port']) ? ftp_ssl_connect($f['host'], $f['port']) : ftp_ssl_connect($f['host']);
}
$f['user'] = str_replace('+', '@', @$f['user']);
$login_result = ftp_login($ftp_conn, $f['user'], @$f['pass']);
if (!$ftp_conn || !$login_result) {
AK_FTP_SHOW_ERRORS ? trigger_error(Ak::t('Could not connect to the FTP server'), E_USER_NOTICE) : null;
return false;
}
$_base_dir = isset($f['path']) ? '/' . trim($f['path'], '/') : '/';
if (defined('AK_FTP_AUTO_DISCONNECT') && AK_FTP_AUTO_DISCONNECT) {
register_shutdown_function(array('AkFtp', 'disconnect'));
}
if (AK_AUTOMATIC_CONFIG_VARS_ENCRYPTION && empty($_pass_encoded)) {
@register_shutdown_function(create_function('', "@Ak::file_put_contents(AK_CONFIG_DIR.DS.'config.php',\n str_replace(AK_FTP_PATH,'PROTECTED:'.base64_encode(Ak::encrypt(AK_FTP_PATH,'HR23JHR93JZ0ALi1UvTZ0ALi1UvTk7MD70')),\n Ak::file_get_contents(AK_CONFIG_DIR.DS.'config.php')));"));
}
}
}
if (isset($base_dir) && $base_dir === 'AK_DISCONNECT_FTP') {
$disconnected = true;
$base_dir = null;
} else {
$disconnected = false;
}
if (!isset($base_dir) && isset($_base_dir) && '/' . trim(ftp_pwd($ftp_conn), '/') != $_base_dir) {
if (!@ftp_chdir($ftp_conn, $_base_dir) && AK_FTP_SHOW_ERRORS) {
trigger_error(Ak::t('Could not change to the FTP base directory %directory', array('%directory' => $_base_dir)), E_USER_NOTICE);
}
} elseif (isset($base_dir)) {
if (!ftp_chdir($ftp_conn, $base_dir) && AK_FTP_SHOW_ERRORS) {
trigger_error(Ak::t('Could not change to the FTP directory %directory', array('%directory' => $base_dir)), E_USER_NOTICE);
}
}
return $ftp_conn;
}