{"id":47,"date":"2006-02-21T15:01:25","date_gmt":"2006-02-21T07:01:25","guid":{"rendered":"http:\/\/www\/zhouhonghe.com\/wordpress\/?p=47"},"modified":"2007-01-29T21:11:02","modified_gmt":"2007-01-29T13:11:02","slug":"php%e5%8a%a0%e8%a7%a3%e5%af%86%e6%ba%90%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/blog.zhouhonghe.com\/?p=47","title":{"rendered":"php\u52a0\u89e3\u5bc6\u6e90\u4ee3\u7801"},"content":{"rendered":"<p>&lt;?php<br \/>\n$key = \"i love you\";<\/p>\n<p>function keyED($txt,$encrypt_key)<br \/>\n{<br \/>\n$encrypt_key = md5($encrypt_key);<br \/>\n$ctr=0;<br \/>\n$tmp = \"\";<br \/>\nfor ($i=0;$i&lt;strlen($txt);$i++)<br \/>\n{<br \/>\nif ($ctr==strlen($encrypt_key)) $ctr=0;<br \/>\n$tmp.= substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1);<br \/>\n$ctr++;<br \/>\n}<br \/>\nreturn $tmp;<br \/>\n}<\/p>\n<p>function encrypt($txt,$key)<br \/>\n{<br \/>\nsrand((double)microtime()*1000000);<br \/>\n$encrypt_key = md5(rand(0,32000));<br \/>\n$ctr=0;<br \/>\n$tmp = \"\";<br \/>\nfor ($i=0;$i&lt;strlen($txt);$i++)<br \/>\n{<br \/>\nif ($ctr==strlen($encrypt_key)) $ctr=0;<br \/>\n$tmp.= substr($encrypt_key,$ctr,1) .<br \/>\n(substr($txt,$i,1) ^ substr($encrypt_key,$ctr,1));<br \/>\n$ctr++;<br \/>\n}<br \/>\nreturn keyED($tmp,$key);<br \/>\n}<\/p>\n<p>function decrypt($txt,$key)<br \/>\n{<br \/>\n$txt = keyED($txt,$key);<br \/>\n$tmp = \"\";<br \/>\nfor ($i=0;$i&lt;strlen($txt);$i++)<br \/>\n{<br \/>\n$md5 = substr($txt,$i,1);<br \/>\n$i++;<br \/>\n$tmp.= (substr($txt,$i,1) ^ $md5);<br \/>\n}<br \/>\nreturn $tmp;<br \/>\n}<\/p>\n<p>$string = \"1111111\";<\/p>\n<p>\/\/ encrypt $string, and store it in $enc_text<br \/>\n$enc_text = encrypt($string,$key);<\/p>\n<p>\/\/ decrypt the encrypted text $enc_text, and store it in $dec_text<br \/>\n$dec_text = decrypt($enc_text,$key);<\/p>\n<p>print \"Original text : $string &lt;Br&gt;n\";<br \/>\nprint \"Encrypted text : $enc_text &lt;Br&gt;n\";<br \/>\nprint \"Decrypted text : $dec_text &lt;Br&gt;n\";<br \/>\n?&gt;<\/p>\n<p>\u6765\u6e90\uff1ahttp:\/\/phpboy.bokeland.com\/blog\/15\/32\/2005\/11\/01\/1846<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php $key = \"i love you\"; function keyED($txt,$encr [&hellip;]<\/p>... ","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47"}],"version-history":[{"count":0,"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.zhouhonghe.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}