[UP]


Manual Reference Pages  - rotate13 (3)

NAME

rotate13(3f) - [M_strings] apply trivial ROT13 encryption to a string (LICENSE:PD)

CONTENTS

Synopsis
Description
References
Example
Author
License

SYNOPSIS

rotate13(input) result(output)

character(len=*),intent(in) :: input character(len=len(input)) :: output

DESCRIPTION

ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the 13th letter after it in the alphabet; wrapping around if necessary.

The transformation can be done using a lookup table, such as the following:

      Input  ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
      Output NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm

ROT13 is used in online forums as a means of hiding spoilers, punchlines, puzzle solutions, and offensive materials from the casual glance. ROT13 has inspired a variety of letter and word games on-line, and is frequently mentioned in newsgroup conversations.

The algorithm provides virtually no cryptographic security, and is often cited as a canonical example of weak encryption.

ROT13 is a special case of the Caesar cipher which was developed in ancient Rome.

    ALGORITHM

Applying ROT13 to a piece of text merely requires examining its alphabetic characters and replacing each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary. A becomes N, B becomes O, and so on up to M, which becomes Z, then the sequence continues at the beginning of the alphabet: N becomes A, O becomes B, and so on to Z, which becomes M. Only those letters which occur in the English alphabet are affected; numbers, symbols, whitespace, and all other characters are left unchanged.

    SAME ALGORITHM FOR ENCODING AND DECODING

Because there are 26 letters in the English alphabet and 26 = 2 x 13, the ROT13 function is its own inverse: so the same action can be used for encoding and decoding. In other words, two successive applications of ROT13 restore the original text (in mathematics, this is sometimes called an involution; in cryptography, a reciprocal cipher).

    TRIVIAL SECURITY

The use of a constant shift means that the encryption effectively has no key, and decryption requires no more knowledge than the fact that ROT13 is in use. Even without this knowledge, the algorithm is easily broken through frequency analysis.

In encrypted normal English-language text of any significant size, ROT13 is recognizable from some letter/word patterns. The words "n", "V" (capitalized only), and "gur" (ROT13 for "a", "I", and "the"), and words ending in "yl" ("ly") are examples.

REFERENCES

Wikipedia, the free encyclopedia

EXAMPLE

Sample program

   program demo_rotate13
   use M_strings, only : rotate13
   implicit none
   character(len=256) :: line
   integer            :: ios
   do
      read(*,’(a)’,iostat=ios)line
      if(ios.ne.0)exit
      write(*,’(a)’)rotate13(line)
   enddo
   end program demo_rotate13

Sample usage:

   demo_rotate13
   United we stand, divided we fall.
   Havgrq jr fgnaq, qvivqrq jr snyy.

AUTHOR

John S. Urban

LICENSE

Public Domain


rotate13 (3) July 05, 2020
Generated by manServer 1.08 from 47913e9d-cb1e-4255-8443-86e25ecf2b45 using man macros.