Rot 13 Encryption
Encryption is an ancient practice of trying to conceal information by scrambling it. Modern encryption techniques are incredibly strong and mathematically sound. But in the past, simpler and more primitive methods were used.
Let's implement a form of encryption known as a Caesar Cipher,
sometimes also known as Rot-13 encryption.
(Rot for rotation, and 13 for one amount that you might rotate.)
Here is how it works. Given a
String and an amount to rotate, we replace each character in the
a new character determined by rotating the original character through a given rotation
For example, given the rotation
String "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ",
"ABC" rotated 3 would be "DEF", and rotated -1 would be " AB". (Note the space at the end of the rotation
Declare and implement a function called
encrypt that, given a
String and an
int amount, returns the passed
String "encrypted" by rotating it the given amount.
("Encrypted" is in scare quotes because this is not by any means a strong method of encryption!)
Use the rotation
String provided above.
If the passed
null you should return
Note that rotation may be negative, which will require some additional care.