懂PHP且懂点C的大神进去
Jun 13, 2016 pm 12:03 PM
nbsp
ord
out
懂PHP且懂点C的大神进来
这是个客户端C版本的解密函数,我需要一个PHP版本的加密函数,麻烦下大神,
<br />void hdth_normal_decode(char * outstr,char * instr)<br />{<br /> int i=0;<br /> int j = 0;<br /> int len = strlen(instr);<br /> for(i=0;i<len;i=i+2) <br /> { <br /> int h=(instr[i]-'c'); <br /> int l=(instr[i+1]-'f'); <br /> char c=(l<<4)+(h&0xf); <br /> outstr[j]=c;<br /> j++;<br /> } <br /><br /> return;<br />}<br />
Copy after login
给个原文转为密文的例子:
<br />原文:www.comunits.net<br />密文:jmjmjmqhflrlplhmqlllgmfmqhqlhlgm<br />
Copy after login
------解决方案--------------------
先移植解密函数到 php
function hdth_normal_decode($in) {<br /> $out = ''; <br /> $len = strlen($in);<br /> for($i=0; $i<$len; $i+=2) {<br /> $h = ord($in{$i}) - ord('c');<br /> $l = ord($in{$i+1}) - ord('f');<br /> $c = ($l << 4) + ($h & 0xf);<br /> $out .= chr($c);<br /> }<br /> return $out;<br />}
Copy after login
function hdth_normal_encode($in) {<br /> $out = '';<br /> $len = strlen($in);<br /> for($i=0; $i<$len; $i++) {<br /> $c = ord($in{$i});<br /> $l = ($c >> 4) + ord('f');<br /> $h = ($c & 0xf) + ord('c');<br /> $out .= chr($h) . chr($l);<br /> }<br /> return $out;<br />}
Copy after login
echo hdth_normal_encode('www.comunits.net');
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
