Problem 1953. Simple Caesar Cypher - shift encrypt a message given an index number
A Caesar cypher is a simple shift encryption method. Your goal is to create a function that allows a user to input a string and a shift index and outputs the shifted cypher-text as a string.
The shift index is an integer that tells the encryption method how many letters to shift each letter in the message forward. For example, a shift index of 3 will shift the letter "a" to be "d", "b" to be "e" and so on. In this problem we will just use the 26 lowercase letters in the english alphabet, and any capital letters in the message should be converted to lowercase. The ordering of letters will wrap around after "z", so that a "y" shifted by 3 will become a "b".
Any integer number (positive, negative, and of any magnitude) should be acceptable as the shift index.
Examples:
caesarShift('zebra',7) --> 'gliyh'
caesarShift('LiOn',-5) --> 'gdji'
Solution Stats
Problem Comments
-
1 Comment
the second test is wrong, the answer should be 'kzxvi'
Solution Comments
Show commentsProblem Recent Solvers87
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
47428 Solvers
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15337 Solvers
-
Find relatively common elements in matrix rows
1959 Solvers
-
Omit columns averages from a matrix
579 Solvers
-
How long is the longest prime diagonal?
391 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!