コード例 #1
0
function rot1_encrypt($string)
{
    $newStr = "";
    for ($i = 0; $i < strlen($string); $i++) {
        $newStr .= incrementLetter($string[$i]);
    }
    return $newStr;
}
コード例 #2
0
ファイル: advent11.php プロジェクト: tgilbers/advent-2015
function incrementLetter(&$str, $pos)
{
    global $alphas;
    if ($str[$pos] == 'z') {
        $str[$pos] = 'a';
        if ($pos != 0) {
            incrementLetter($str, $pos - 1);
        }
    } else {
        $str[$pos] = chr(ord($str[$pos]) + 1);
    }
}