Sha256: 46c36863622598a18fc0b4c4f839506daab1791b372024d816ed4c0b07d9e292
Contents?: true
Size: 448 Bytes
Versions: 122
Compression:
Stored size: 448 Bytes
Contents
package rotationalcipher import ( "unicode" ) // RotationalCipher is an implementation for the rotational cipher exercise. func RotationalCipher(plain string, shiftKey int) string { var cipher []rune for _, ru := range plain { if unicode.IsUpper(ru) { ru = rune('A' + (int(ru-'A')+shiftKey)%26) } else if unicode.IsLower(ru) { ru = rune('a' + (int(ru-'a')+shiftKey)%26) } cipher = append(cipher, ru) } return string(cipher) }
Version data entries
122 entries across 122 versions & 1 rubygems