Skip to main content

rot13

Function rot13 

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

Rotate every ASCII letter of s by thirteen positions, wrapping within its own case.

Non-letters — digits, punctuation, whitespace, and every non-ASCII character — pass through unchanged. ROT13 is its own inverse, so encoding and decoding are one function.

use safe_decode::rot13;
assert_eq!(rot13("Hello, World!"), "Uryyb, Jbeyq!");
assert_eq!(rot13(&rot13("round trip")), "round trip");