时间:2021-07-01 10:21:17 帮助过:55人阅读
void hdth_normal_decode(char * outstr,char * instr)
{
int i=0;
int j = 0;
int len = strlen(instr);
for(i=0;i{ 
int h=(instr[i]-'c');
int l=(instr[i+1]-'f');
char c=(l<<4)+(h&0xf);
outstr[j]=c;
j++;
}
return;
}
原文:www.comunits.net
密文:jmjmjmqhflrlplhmqlllgmfmqhqlhlgm
function hdth_normal_decode($in) {
  $out = ''; 
  $len = strlen($in);
  for($i=0; $i<$len; $i+=2) {
    $h = ord($in{$i}) - ord('c');
    $l = ord($in{$i+1}) - ord('f');
    $c = ($l << 4) + ($h & 0xf);
    $out .= chr($c);
  }
  return $out;
}然后求其逆运算function hdth_normal_encode($in) {
  $out = '';
  $len = strlen($in);
  for($i=0; $i<$len; $i++) {
    $c = ord($in{$i});
    $l = ($c >> 4) + ord('f');
    $h = ($c & 0xf) + ord('c');
    $out .= chr($h) . chr($l);
  }
  return $out;
}测试一下echo hdth_normal_encode('www.comunits.net');jmjmjmqhflrlplhmqlllgmfmqhqlhlgm