Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7886949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:27:09+00:00 2026-06-03T05:27:09+00:00

I found a string after reading funny things about Jon Skeet, and I guessed

  • 0

I found a string after reading funny things about Jon Skeet, and I guessed that it was in ROT13. Before just checking my guess, I thought I’d try and decrypt it with PHP. Here’s what I had:

$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;
}

My string comes back as AIaf you aasakaead ABruacae Sacahnaeaiaer to adaeacrypt tahais, ahae'ad acrusah your sakualal waitah ahais alaauagah.

My logic seems quite close, but it’s obviously wrong. Can you help me with it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:27:10+00:00Added an answer on June 3, 2026 at 5:27 am

    Here is a working implementation, without using the nested loop. You also don’t need to split the string into an array, since you can index individual characters just like an array with strings in PHP.

    You need to know that ASCII upper-case characters range from 65 – 99, and lower-case characters range from 97 – 122. If the current character is in one of those ranges, add 13 to its ASCII value. Then, you check if you should have rolled over to the beginning of the alphabet. If you should’ve rolled over, subtract 26.

    $string = "Vs lbh nfxrq Oehpr Fpuarvre gb qrpelcg guvf, ur'q pehfu lbhe fxhyy jvgu uvf ynhtu.";
    
    for ($i = 0, $j = strlen( $string); $i < $j; $i++) 
    {
        // Get the ASCII character for the current character
        $char = ord( $string[$i]); 
    
        // If that character is in the range A-Z or a-z, add 13 to its ASCII value
        if( ($char >= 65  && $char <= 90) || ($char >= 97 && $char <= 122)) 
        {
            $char += 13; 
    
            // If we should have wrapped around the alphabet, subtract 26
            if( $char > 122 || ( $char > 90 && ord( $string[$i]) <= 90)) 
            {
                $char -= 26;
            }
        }
        echo chr( $char);
    }
    

    This produces:

    If you asked Bruce Schneier to decrypt this, he’d crush your skull with his laugh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found it odd that a string method operation on a string object doesn't
I've found a Perl regexp that can check if a string is UTF-8 (the
I just found some strange behavior of database's order by clause. In string comparison,
I haven't found my answer after reading through all of these posts, so I'm
Beginner programmer here. after a bunch of reading about 'variables' which dont exist in
I have found a proper solution to my problem but even after reading mysql
I just joined StackOverflow after having found many great answers here in the past.
I want to use a particular string found in the Values folder into normal
I found an example in MSDN for string to datetime conversion. But it doesn't
I am getting a Method not found: 'Boolean MyCompany.LibraryAssembly.SomeFunction(System.String)' exception/error when running a VB.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.