【问题标题】:PHP Create an encode algorithm?PHP 创建一个编码算法?
【发布时间】:2018-03-02 05:01:30
【问题描述】:
function deCode_Me($strContent, $cKey){
    $hRet = 0;
    $sRet = "";
    foreach( str_split($strContent) as $nKey ){
        $sRet .= chr(ord($nKey) ^ ord($cKey[$hRet++ % strlen($cKey)]));
    }
    return $sRet;

}

如何为上述解析器制作编码器。 正好相反?

【问题讨论】:

  • 执行相同的步骤,但相反。提示:^ 是异或,A ^ B = CC ^ B = A
  • 我很紧张。你会为我做吗? (对我来说很重要)我不会写加密器
  • 没有。这不是代码编写服务。
  • Stack Overflow不是免费的代码编写服务。您应该尝试自己编写代码。在doing more research 之后,如果您有问题,您可以发布您尝试过的内容,并清楚地解释什么不起作用并提供Minimal, Complete, and Verifiable example。我建议阅读How to Ask 一个好问题和the perfect question。另外,请务必将tour阅读this

标签: php algorithm decode encode


【解决方案1】:
function encode_Me($strContent, $cKey)
{
$key = $cKey;
$text = $strContent;
$outText = '';
for ($i = 0; $i < strlen($text); $i++)
    {
    for ($j = 0; $j < strlen($key); $j++, $i++)
        {
        $outText.= $text
            {
            $i} ^ $key
                {
                $j};
                }
            }

        return $outText;
        }

工作! :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-31
    • 1970-01-01
    • 1970-01-01
    • 2014-09-19
    • 1970-01-01
    • 2011-04-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多