[PHP] Mcrypt ¾ÏÈ£È/º¹È£È
ÆäÀÌÁö 1 Áß 1
[PHP] Mcrypt ¾ÏÈ£È/º¹È£È
function encrypt($string,$key) {
srand((double) microtime() * 1000000);
$key = md5($key);
$td = mcrypt_module_open('des', '','cfb', '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
if (mcrypt_generic_init($td, $key, $iv) != -1) {
$c_t = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$c_t = $iv.$c_t;
return $c_t;
}
}
$id= encrypt(english,title);
<a href=view.php?id=<?=htmlentities(urlencode($id))?>>view</a>
------------------------------------------------------------------
view.php ³»¿ë
function decrypt($string,$key) {
$key = md5($key);
$td = mcrypt_module_open('des', '','cfb', '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = substr($string,0,$iv_size);
$string = substr($string,$iv_size);
if (mcrypt_generic_init($td, $key, $iv) != -1) {
$c_t = mdecrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $c_t;
}
}
echo decrypt($_REQUEST['id'],title);
srand((double) microtime() * 1000000);
$key = md5($key);
$td = mcrypt_module_open('des', '','cfb', '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
if (mcrypt_generic_init($td, $key, $iv) != -1) {
$c_t = mcrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
$c_t = $iv.$c_t;
return $c_t;
}
}
$id= encrypt(english,title);
<a href=view.php?id=<?=htmlentities(urlencode($id))?>>view</a>
------------------------------------------------------------------
view.php ³»¿ë
function decrypt($string,$key) {
$key = md5($key);
$td = mcrypt_module_open('des', '','cfb', '');
$key = substr($key, 0, mcrypt_enc_get_key_size($td));
$iv_size = mcrypt_enc_get_iv_size($td);
$iv = substr($string,0,$iv_size);
$string = substr($string,$iv_size);
if (mcrypt_generic_init($td, $key, $iv) != -1) {
$c_t = mdecrypt_generic($td, $string);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $c_t;
}
}
echo decrypt($_REQUEST['id'],title);
Admin- Admin
- °Ô½Ã¹° °¹¼ö : 380
Age : 54
Registration date : 2008-08-09
Character sheet
test:
ÆäÀÌÁö 1 Áß 1
Permissions in this forum:
´ä±ÛÀ» ¿Ã¸± ¼ö ¾ø½À´Ï´Ù
2009-12-13, 10:31 pm by Admin
» html ÁÖ¼Ò Ç¥½ÃÁÙ º¯¼ö, PHP º¸¾È
2009-11-27, 6:04 am by Admin
» [MySQL] RANKING
2009-10-31, 5:01 am by Admin
» °Ë»öÈÄ Ã¢ À̵¿ÇÏ´Â ÀÚ¹Ù½ºÅ©¸³Æ®
2009-10-17, 8:56 am by ldcsh
» HTML SELECT ÀÀ¿ë
2009-10-17, 7:34 am by Admin
» HTML INPUT BUTTON Type
2009-10-17, 6:40 am by Admin
» Çѱ¹ÀÇ ÀüÅë»ö[Æß±Û]
2008-11-29, 8:25 pm by benis
» ¸ÅÅ©·Î »ç¿ë¹æ¹ý
2008-11-14, 9:38 am by kyg6659
» ÀÚÁÖ »ç¿ëÇÏ´Â MySQL Äõ¸®¹®
2008-11-14, 9:23 am by kyg6659