REBOL [
    Title:   "Rot-13"
    Author:  "Allen Kamp"
    Email:   allenk@powerup.com.au
    Date:     21-Oct-1999
    File:    %rot-13.r
    version: 1.0.1  
    Purpose: {To Encode and Decode Rot-13 strings}
    Notes:   {
              Rotates Roman alphabet chars by 13 places. Case is preserved.
              Used in Newsgroups to prevent accidental reading of content.
    }
    Usage:   {To encode >> rot-13 "This is a test" == "Guvf vf n grfg" 
              To decode, just use rot-13 again >> rot-13 "Guvf vf n grfg" == "This is a test"
    }
    Category: [util 2]
]

rot-13: func [
    {Converts a string to or from Rot-13}
    data [any-string!]
    /local scrambled rot-chars rot-char
][
    rot-chars: {anabobcpcdqderefsfgtghuhivijwjkxklylmzmANABOBCPCDQDEREFSFGTGHUHIVIJWJKXKLYLMZM}
    scrambled: copy ""
    foreach char data [
        if none? (rot-char: select/case rot-chars char) [rot-char: char]
        insert tail scrambled :rot-char
    ]
    return scrambled
]

; example
; print rot-13 "Rebol Rules"