PHP代码加密与解,但不支持中文. <?php /* @名称:PHP加密/解密 @更新:2009年9月22日 20:23:47 */ function phpencode($code) { $code = str_replace(array('<?php','?>','<?PHP'),array('','',''),$code); $encode = base64_encode(gzdeflate($code)); // 开始编码 $encode = '<?php'."\neval(gzinflate(base64_decode("."'".$encode."'".")));\n?>"; return $encode; } function phpdecode($code) { $code = str_replace(array('<?php','<?PHP',"eval(gzinflate(base64_decode('","')));",'?>'),array('','','','','',''),$code); $decode = base64_decode($code); $decode = @gzinflate($decode); return $decode; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP加密/解密</title> <style type="text/css" media="all"> html, body { margin: 0;padding: 0; } body { color: #333; font: 12px Tahoma,Lucida Grande, sans-serif; margin: 9%; } a { color: #0055CC; } img { border: 0px solid #CCC; } h1 { margin: 0; } h3 { color: #555; font-size: 1.6em; font-weight: normal; margin: 0; } pre { color: #0055CC; font-size: 1.1em; line-height: 1.2; margin: 0.25em 0; } p { margin: 0.65em 0; } #ads { border-left: 1px solid #eee; float: right; margin: 0 0 2em 2.5em; padding-left: 3px; width: 160px; } #source { margin-bottom: 2.5em; } pre { overflow: auto; padding:1em 0; } h2 { position: relative; top: 0.5em; } </style> </head> <body> <h3>PHP加密/解密</h3> <form method="post"> <textarea name="source" cols="55" rows="8"> <?php if(!empty(
{1}
POST['source'])) {if({1}
POST['button']=='加密') {echo htmlspecialchars(phpencode(stripcslashes({1}
POST['source'])));}if({1}
POST['button']=='解密') {echo htmlspecialchars(phpdecode(stripcslashes({1}
POST['source'])));}}?></textarea><?phpif(!empty({1}
POST['source'])){if({1}
POST['button']=='加密') {echo '<br /><br />加密成功.';}if({1}
POST['button']=='解密') {echo '<br /><br />解密成功.';}}else{echo '<br /><br />利用 base64+gzinflate 对您的PHP代码进行压缩,可以一定程度上保护您的代码版权和减小代码的体积。';}?><br /><br /><input type="submit" name="button" value="加密"><input type="submit" name="button" value="解密"></form></body></html>
PHP加密/解密
最新推荐文章于 2021-11-01 09:14:31 发布