用PHP实现ROT13

Jez*_*mas 3 php encryption rot13

我在阅读了有关Jon Skeet的有趣内容之后找到了一个字符串,我猜这是在ROT13中.在检查我的猜测之前,我想我会尝试用PHP解密它.这就是我的所作所为:

$string = "Vs lbh nfxrq Oehpr Fpuarvre gb qrpelcg guvf, ur'q pehfu lbhe fxhyy jvgu uvf ynhtu.";
$tokens = str_split($string);
for ($i = 1; $i <= sizeof($tokens); $i++) {
    $char = $tokens[$i-1];
    for ($c = 1; $c <= 13; $c++) {
        $char++;
    }
    echo $char;
}
Run Code Online (Sandbox Code Playgroud)

我的字符串回来了 AIaf you aasakaead ABruacae Sacahnaeaiaer to adaeacrypt tahais, ahae'ad acrusah your sakualal waitah ahais alaauagah.

我的逻辑似乎很接近,但显然是错的.你能帮帮我吗?

dam*_*anb 7

试试str_rot13.

http://us.php.net/manual/en/function.str-rot13.php

它不需要自己创建,它是内置的.