Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source pure

Package rot13 ports Go's classic ROT13 example — the one used to teach strings.Map and io.Reader in the standard libr...

Readme View source

gno.land/p/moul/x/daily/rot13/v0

ROT13 / Caesar letter-rotation cipherRot13, Caesar.

Pure strings.Map logic over ASCII letters; everything else passes through untouched. ROT13 shifts each letter 13 places and, since the alphabet has 26 letters, is its own inverse. Caesar generalizes it to any shift (negative and large shifts normalized into [0,26)). Ports Go's classic ROT13 teaching example.

1import "gno.land/p/moul/x/daily/rot13/v0"
2
3s := rot13.Rot13("Hello, Gno!") // "Uryyb, Tab!"
4d := rot13.Rot13(s)             // "Hello, Gno!" (own inverse)
5c := rot13.Caesar("attack", 3)  // "dwwdfn"

Live demo: r/moul/x/daily/rot13demo · render it at /r/moul/x/daily/rot13demo/v0.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package rot13 ports Go's classic ROT13 example — the one used to teach strings.Map and io.Reader in the standard library docs — to gno as a reusable pure package. The core is a pure letter-rotation cipher over ASCII: ROT13 shifts each letter 13 places, which (since the alphabet has 26 letters) makes ROT13 its own inverse. Caesar generalizes it to any shift.

Everything here is pure strings/unicode logic: no state, no randomness, no clock.

A live demo of this package is at r/moul/x/daily/rot13demo(/r/moul/x/daily/rot13demo/v0).

Functions 2

func Caesar

1func Caesar(s string, shift int) string
source

Caesar generalizes ROT13 to an arbitrary shift. Negative and large shifts are normalized into [0,26). Only ASCII letters move; anything else passes through unchanged. Caesar(s, 13) is exactly Rot13(s).

func Rot13

1func Rot13(s string) string
source

Rot13 applies the ROT13 substitution cipher, rotating ASCII letters by 13 and leaving every other byte untouched. Because 13 is half of 26, Rot13(Rot13(s)) == s — the cipher is its own inverse. This mirrors the canonical strings.Map example from the Go docs.

Imports 1

  • strings stdlib

Source Files 3