2016-day04: caesar shift algo, validating checksum

This commit is contained in:
alexchao26
2020-12-20 23:57:01 -05:00
parent 2dbce844d4
commit 8a15e0eb82
3 changed files with 182 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
package algos
// CaesarShift performs a forwards caesar shift of a given shiftAmount
func CaesarShift(in string, shiftAmount int) string {
var result string
for _, char := range in {
// char to ascii number
ascii := int(char) - int('a')
ascii += shiftAmount
ascii %= 26
ascii += int('a')
result += string(rune(ascii))
}
return result
}