Last active
June 15, 2016 08:40
-
-
Save poppen/f6200450d68038537c3e26efef3c4826 to your computer and use it in GitHub Desktop.
Revisions
-
poppen revised this gist
Jun 15, 2016 . No changes.There are no files selected for viewing
-
poppen renamed this gist
Jun 15, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
poppen created this gist
Jun 15, 2016 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ package main import ( "io" "os" "strings" ) type rot13Reader struct { r io.Reader } func (r *rot13Reader) Read(b []byte) (int, error) { l, e := r.r.Read(b) for i, c := range b { if c == ' ' || c == '!' { continue } if ('a' <= c && c <= 'm') || ('A' <= c && c <= 'M') { b[i] = c + 13 } else { b[i] = c - 13 } } return l, e } func main() { s := strings.NewReader("Lbh penpxrq gur pbqr!") r := rot13Reader{s} io.Copy(os.Stdout, &r) }