Transaction

825ECFCB19597B…D39DA51D8712

Block 25,951 · index 0 · indexed

Summary

Hash
825ECFCB19597B00FE408AA86BDA4A03B2DB0419F9E7034D63BAD39DA51D8712
Block
25,951
Size
3558 bytes
Gas used
7,976,765 / 9,572,178
Fee
1000000ugnot
Memo
gnopublish
Status
success

Messages

#1AddPackagegno.land/p/moul/x/daily/rot13/v09 arguments

Arguments · 9

  1. #1rot13
  2. #2README.md
  3. #3# `gno.land/p/moul/x/daily/rot13/v0` **ROT13 / Caesar letter-rotation cipher** — `Rot13`, `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. ```go import "gno.land/p/moul/x/daily/rot13/v0" s := rot13.Rot13("Hello, Gno!") // "Uryyb, Tab!" d := rot13.Rot13(s) // "Hello, Gno!" (own inverse) c := rot13.Caesar("attack", 3) // "dwwdfn" ``` **Live demo:** [`r/moul/x/daily/rot13demo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/rot13demo/v0) · render it at [`/r/moul/x/daily/rot13demo/v0`](https://gno.land/r/moul/x/daily/rot13demo/v0). <!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) --> --- Part of **[moul/gno-contracts](https://github.com/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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md). <!-- END GNOCONTRACTS FOOTER -->
  4. #4gnomod.toml
  5. #5module = "gno.land/p/moul/x/daily/rot13/v0" gno = "0.9"
  6. #6rot13.gno
  7. #7// 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). package rot13 import "strings" // 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. func Rot13(s string) string { return strings.Map(rot13Rune, s) } // rot13Rune is the mapping function handed to strings.Map — the heart of the // classic example. func rot13Rune(r rune) rune { switch { case r >= 'a' && r <= 'z': return 'a' + (r-'a'+13)%26 case r >= 'A' && r <= 'Z': return 'A' + (r-'A'+13)%26 } return r } // 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 Caesar(s string, shift int) string { sh := rune(((shift % 26) + 26) % 26) return strings.Map(func(r rune) rune { switch { case r >= 'a' && r <= 'z': return 'a' + (r-'a'+sh)%26 case r >= 'A' && r <= 'Z': return 'A' + (r-'A'+sh)%26 } return r }, s) }
  8. #8/gno.MemPackageType
  9. #9 MPUserProd

Result log

msg:0,success:true,log:,events:[]

← Back to block 25,951