Become a leader in the IoT community!
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Join our community of embedded and IoT practitioners to contribute experience, learn new skills and collaborate with other developers with complementary skillsets.
Julius Caesar protected his confidential information by encrypting it using a cipher. Caesar’s cipher shifts each letter by a number of letters. If the shift takes you past the end of the alphabet, just rotate back to the front of the alphabet. In the case of a rotation by 3, w, x, y and z would map to z, a, b and c.
Create a function that takes a string s (text to be encrypted) and an integer k (the rotation factor). It should return an encrypted string.
**Resources**
[Caesar Cipher](https://www.dcode.fr/caesar-cipher)
[ASCII Table](https://en.wikipedia.org/wiki/File:ASCII-Table.svg)
**Examples**
caesarCipher("middle-Outz", 2) β "okffng-Qwvb"
// m -> o
// i -> k
// d -> f
// d -> f
// l -> n
// e -> g
// - -
// O -> Q
// u -> w
// t -> v
// z -> b
caesarCipher("Always-Look-on-the-Bright-Side-of-Life", 5)
β "Fqbfdx-Qttp-ts-ymj-Gwnlmy-Xnij-tk-Qnkj"
caesarCipher("A friend in need is a friend indeed", 20)
β "U zlcyhx ch hyyx cm u zlcyhx chxyyx"
**Notes**
All test input will be a valid ASCII string.
CONTRIBUTE TO THIS THREAD