Last active
January 15, 2017 00:09
-
-
Save amstee/ae825dd690968f5533a50bdeff2b86d2 to your computer and use it in GitHub Desktop.
An answer for the exercise rot reader
This file contains hidden or 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 characters
| import ( | |
| "io" | |
| ) | |
| type rot13Reader struct { | |
| r io.Reader | |
| } | |
| func (reader *rot13Reader) Read(param []byte) (int, error) { | |
| si, err := reader.r.Read(param) | |
| for i := 0; i < si; i++ { | |
| if ((param[i] + 13) <= 'z') { | |
| param[i] = param[i] + 13 | |
| } else { | |
| param[i] = param[i] - 13 | |
| } | |
| } | |
| return si, err | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment