• Yet Another Lurker (unregistered)

    Holy sweet flaming cow crap, I think I think I just broke something while attempting to laugh and choke on my own vomit simultaneously.

  • Null (unregistered)

    I have no idea where to begin...I mean, that may have worked great for Caesar, but its time to join the 21st century.

  • Myself (unregistered)

    Woah pretty good. How could one EVER find the pattern??

  • artistech (unregistered)

    Aww, what a cute implementation of a letter-substitution cipher. Caeser would be proud. Careful; don't get too close, it might bite.

  • Phil Scott (unregistered)

    or fher gb qevax lbhe binygvar

  • Alex Papadimoulis (unregistered)

    Hahaha! Great one Phil! Now if only I had a rot13 decoder ring ...

  • arty (unregistered)

    You and your drink-mix conspirators cannot fool a cypherpunk such as myself!

  • Randy Glenn (unregistered)

    That would have been so much easier if he'd just done some addition with a modulus on the ASCII values.

  • Roberto (unregistered)

    GNU Source-highlight (http://www.gnu.org/software/src-highlite/source-highlight.html) handles PHP3, and outputs (X)HTML.

  • black (unregistered)

    ... wishing php had the rot13 function (www.php.net/rot13)

  • [email protected] (Scott Mitchell) (unregistered)

    Someone ought to remind this fellow what a poor substitution cipher might just cost you...

    "The correspondence between Mary Queen of Scots and Anthony Babington was encrypted with a substitution cipher. ... However, the ninth-century Arab codebreaker al-Kindi realised that there is an effective way of cracking the substitution cipher. Every letter in a language appears with a certain average frequency, so that in English, for example, 'e' accounts for 13% of all letters, whereas 'z' accounts for less than 1%. Whichever letter is substituted for the original letter will take on the original frequency. So by analysing the frequency of the different letters in a code you can work out which letter each substituted letter represents.

    Walsingham's codebreaker used this technique to decipher the letters of Mary Queen of Scots. The letters were used as evidence against her, and she was found guilty of treason and executed in 1587."
    http://www.channel4.com/science/microsites/S/secrecy/page1c_t.html

  • Dominik Wagner (unregistered)

    Does anyone have a good PHP -> HTML converter thingy that is not written in PHP?

    Yes, me :-)

  • asdfs (unregistered)

    Alex: you can use the output from the Source-highlight mentioned above: http://naivist.net/caesar.html
    (Sorry, it becomes quite large...)

  • Nick D (unregistered)

    ROFL

  • Guayo (unregistered)

    SVANYL!6!6!6! JGS YBY NA RAPELCGVBA NYTBEVGUZ GNUG V PNA CHG VA ZNU CEBTEZF66!66! BZT JGS YBY
    ABJ NIRELBAR JVY FR ZNU 828G UNK5E FX6YMM!!!! YBYBY
    A8JORV?F!6!!!!6 OUBYQ GURLER VF N AH UNX8E VA 7JA!! JGS
    NY666! HE ONRF E OYBAT 7 HF.!66!!!66!

  • asdfs (unregistered)
  • dave g (unregistered)
  • dave g (unregistered)
  • Stan Rogers (unregistered)

    I wouldn't have reached further back in history than Conan Doyle's "The Dancing Men". Or Hofstadter's Eta Oin/SHRLU dialog....

  • rs (unregistered)

    Phil - You have submitted the perfect response! You have probably been waiting for years to use it, but it was worth the wait. Well done.

  • Joao Ribeiro (unregistered)

    I assume that he is not aware that PHP includes a function called <a href="http://www.php.net/manual/en/function.str-rot13.php"str_rot13()</a>...

  • Elliott Back (unregistered)

    You might also want devPHP, which has a good syntax highlighter built in.

    http://devphp.sourceforge.net/

  • Chris Cooper (unregistered)

    Oh you guys!

    Everyone knows that this ROT13 (and ROT5 on the digits too) cypher is virtually uncrackable.
    It would take all the computing power available longer than all the time in the universe to beat this... Or is it that other one, the one with the prime number factoring thingy...
    Anyway its really hard I tell you.

  • Anonymous Coward (unregistered)

    In the programmer's defense, the PHP rot13 function did not exist when the code was originally written.


    That still doesn't excuse the fact that rot13 was used for "security", or the horrendous implementation.

  • Craig Gomes (unregistered)

    Wow, just slightly more secure than writing it sdrawkcab.

  • foxyshadis (unregistered)

    I know someone who can read rot13. Kinda rusty at it, but it's been almost ten years since the heyday of usenet anyway. Remember that joke about levels of usenet users? He lived them. ^_~

  • foxyshadis (unregistered)

    Oh, I forgot, there's a mini-wtf in its implementation. PHP has a function made to do this: strtr(). Just call return strtr($string,$shift_array); and you're done. Isn't using a for loop with three identical substring calls and one-byte-longer reallocation calls every iteration the quintessenal VB method?

  • Stephen Thorne (unregistered)

    Yeah, syntax highlighting for just about any language. What you need is:

    vim: <a target="_new" href="http://www.vim.org/">http://www.vim.org/

    Open it in vim, and type this:
    :source C:\path\to\vim\syntax\2html.vim<enter>

    There are some better scripts available from <a target="_new" href="http://www.vim.org/">http://www.vim.org/ in the scripts area, 'syn2html', 'code2html', etc. vim supports >400 languages with its syntax highlighting....

  • fogelman (unregistered)

    So PHP with all it's glory does not contain the Perl etc tr/abcd/wtf?/ syntax? nice.

    I especially love string catenations.
    They are so fast and efficient!

  • foxyshadis (unregistered)

    fogel, strtr does that. strtr('adbecf','abc','def') is tr/adbecf/abc/def. However, since it doesn't have support for regular expressions, the strings have to be explicitly written out. (Not usually a bad idea for its usual uses.)

  • po (unregistered)

    wtf, that looks alot like rot13 to me... it was years since i last looked at something like that

    snyhpung!

  • Zka (unregistered)

    LOL. this rox.

  • po (unregistered)

    wtf, and $case_match is obviously defaults to a string, why does he compare it against a boolean, that is the one thing i hate about php, you can do program as stupid as possible and they still works.. that must be why so many people "know" php :/

  • Grail (unregistered)

    Or you could just do the obvious thing and employ str_rot13() to do the hard work for you...

  • Mike Woodhouse (unregistered)

    Well I can't see what all those arrays are for - why not just look through the string and handle the translation with a big If (or select/case if PHP has that).

    Could this be renamed PCP? (Pretty Crap Privacy) ?

  • drift (unregistered)

    goot highlightning tool with GUI:

    http://www.andre-simon.de/

  • Centaur (unregistered)

    +1 in Internationalization for supporting encodings where Latin letters are not contiguous :)
    Though I’m sure it will fail when tested on MBCS strings. Give that +1 back.

  • Raymond Lewallen (unregistered)

    Man, that's just batshit fucking loco right there.

  • TheF0o1 (unregistered)

    I find it interesting how some people obviously don't read the comments before commenting themselves. Maybe it's human nature, but that's a WTF to me.

    Also, I think the implementation of this function is more of a WTF than the fact that it's a ROT13 algorithm. Sometimes obfuscation is sufficient, and hard encryption is not necessary. Of course, as some of us like to point out, we can't prove the inappropriateness of the function without more context. On the other hand, the name of the function, "encryptStr", is often evidence of it's intention.

  • Stephen Caldwell (unregistered)

    I like PHP but I really think that you should stop posting PHP WTFs. It seems to bring the overall intelligence level of the commenters down a few notches. Lets stick with something serious. Like C and VB.

    smirk

  • Jugernaut (unregistered)

    "I broke it with this."

    "A Drogen's Decoder Wheel? They put these into cereal boxes for kid!"

    "Yeah, I found it in a box of, uh . . . Lucky Charms."

    Hail Caesar!

  • beelzebill (unregistered)

    Personally, I prefer double ROT13 encoding for the additional security.

  • Carl (unregistered)

    I offered a work collegue the chance the optimise the above function and convert it to python, thus giving him the chance to show off his mad coding sk1llz.

    He came up with :

    #!/usr/bin/python
    import sys
    a = sys.stdin.read(1)
    while a:
    sys.stdout.write( chr(ord(a) + 13))
    a = sys.stdin.read(1)

    +1 for knowing about chr() and ord()
    +1 for making it into a shell script, thus making it callable from just about everything
    -10 for having it work for the letters a-m and A-M only.
    -100 for being the first person to implement ROT-13 in such a way as to require a UNROT-13 function.

  • PS (unregistered)
    cindy:
    Re: $_PHP["encryption"]

    OT: You know your blog is popular when you have spambots exploiting your hand-written comment system - and said spambots get HTML escaping done better than you.

Leave a comment on “$_PHP["encryption"]”

Log In or post as a guest

Replying to comment #:

« Return to Article