암호화(encrypt) Sample

<?php
/**
 * Encryption Class
 *
 * Created on 2011. 11. 15.
 * @author 불의회상 <hoksi2k@hanmail.net>
 * @package library
 * @subpackage controllers
 * @version 1.0
 */
class Encrypt_lib extends CI_Controller {
	function __construct() {
		parent::__construct();
		
		// Load Encrypt library
		$this->load->library('encrypt');
	}
	
	function index() {
		$str = '코드이그나이터와 함께 즐거운 코딩 하세요.';
		$key = '!2dfesa@#%$765jile<>kj;loeploe{}';

		$data = array(
			'source_str' => $str,
			'customer_key' => $key,
			'encrypt_str' => $this->encrypt->encode($str),
			'ckey_encrypt' => $this->encrypt->encode($str, $key),
		);
		
		$this->load->view('encrypt_lib_sample', $data);
	}
}
<?php $this->load->view('inc/header')?>

Default Key Encryption (config.php에 정의된 기본키 사용)
<hr />
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th>구분</th>
  <th>데이타</th>
</tr>
</thead>
<tbody>
<tr>
  <th width="10%">Source String</th>
  <td><?php echo $source_str;?></td>
</tr>
<tr>
  <th>Encode</th>
  <td><?php echo $encrypt_str;?></td>
</tr>
<tr>
  <th>Decode</th>
  <td><?php echo $this->encrypt->decode($encrypt_str);?></td>
</tr>
</tbody>
</table>

Customer Key Encryption (사용자가 임의로 정의한 키 사용)
<hr />
<table class="tablesorter" border="0" cellpadding="0" cellspacing="1">
<thead>
<tr>
  <th>구분</th>
  <th>데이타</th>
</tr>
</thead>
<tbody>
<tr>
  <th width="10%">Source String</th>
  <td><?php echo $source_str;?></td>
</tr>
<tr>
  <th width="10%">Customer Key</th>
  <td><?php echo $customer_key;?></td>
</tr>
<tr>
  <th>Encode</th>
  <td><?php echo $ckey_encrypt;?></td>
</tr>
<tr>
  <th>Decode</th>
  <td><?php echo $this->encrypt->decode($ckey_encrypt, $customer_key);?></td>
</tr>
</tbody>
</table>


<?php $this->load->view('inc/footer')?>

© Copyright by hoksi(Page rendered in 0.0062 seconds)