Skip to main content

rot13

Function rot13 

Source
pub fn rot13(input: &str) -> String
Expand description

Applies ROT13 cipher to the input.

ROT13 is a simple letter substitution cipher that replaces each letter with the letter 13 positions after it in the alphabet. Since there are 26 letters, applying ROT13 twice returns the original text (it’s self-inverse). Numbers and special characters remain unchanged.

§Use Cases

  • Simple Obfuscation: Hide spoilers or answers in plain sight
  • Email Protection: Obfuscate email addresses from spam bots
  • Red Team: Basic payload obfuscation (weak, easily detected)
  • Puzzles/CTF: Classic cipher for encoding challenges

§Examples

use redstr::rot13;

assert_eq!(rot13("Hello"), "Uryyb");
assert_eq!(rot13("Uryyb"), "Hello"); // ROT13 is reversible

// Obfuscate email addresses
let email = rot13("user@example.com");
assert_eq!(email, "hfre@rknzcyr.pbz");

// Hide spoilers
let spoiler = rot13("The butler did it!");
assert_eq!(spoiler, "Gur ohgyre qvq vg!");

// Applies to alphabetic characters only
assert_eq!(rot13("test123!"), "grfg123!");