I assume everyone here is familiar with the Caesar Cipher that shifts letters to a certain index. https://en.wikipedia.org/wiki/Caesar_cipher for those who still needs introduction.
But, we can all agree that plain Caesar is unfun and way too easy. So here's a version that also shifts characters around. This version first applies a cyclic position shift of a given amount to the string, for each character in the string separated with punctuations (space counts as character in this context, positive index means to the right).
Hello world with shift +3 becomes
Hello! World becomes
lloHe!rld Wo with the same shift however because the ! separated the string.
After that, your program applies the Caesar cipher to the shifted text, and outputs the result. (easy enough)
The first example becomes
uogKhoor zr after the Caesar cipher of +3.
The second example becomes
iilEb!oia Tl after a Caesar shift of -3 (or +23 in alphabets)
As seen above, the index of the two shifts may or may not be equal.
Write a encode and decode program or function (or whatever your language of choice calls them), they may or may not be the same one. It must implement the aforementioned rules of double shifting, and the decode function must successfully reverse it.
Your program must at the very least function on ASCII characters, ASCII 0-9 (48-57, inclusive), A to Z (65-90), a to z (97-122) and Space (32) counts as characters in this context, with every other ASCII character counting as punctuation and breaking up the string.
Bonus points to those whose program functions on your language of choice's codebase. Since non-ASCII language contain special characters the "punctuation" rule is omitted in this use case. You only need to implement the cyclic shift and then the Caesar shift on your language's codebase.
¡¢£¤ in Jelly becomes
©¤¥¦ with a position shift of +1 and Caesar shift of -253.
You may assume:
The index input are integers. It may be negative or zero.
If only one number is provided, encode both shifts with that number.
If no number is provided, perform whatever default shifts your heart desire (except 0 and 0, that is boring).
Edit: Due to overwhelming demand, you may assume that there will be at least one number provided. Code that has defaults would still be preferred but no extra scoring.
The input string is in ASCII. Or in your language's codebase if you decide to input that to your program.
Of course programs that successfully include their codebase will be prioritized. Include the shifted version of your program in your answer to reflect this.
The other criteria is lowest byte wins. This counts both the encoder and decoder. List the sum and respective length separately please.
+3 -5 "Hello,world" becomes "ggjCz,mgyrj" +10 "Implement a Caesar Cipher with a Digit Shift" becomes "sqsd Crspd Swzvowoxd k Mkockb mszrob gsdr k N" -2 -11 "Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift." becomes "thpg rxewtgRp,ahd zcdlc ph Rpthpg p'rxewtgh ,wt hwxui rxewtg i,pthpg'h rdst dg Rpthpg hwxui R."
PS. Of course I am aware that the two shifts can be carried out in any order and produce the same result, it is just my way of visualizing things. Plus, the first input means position shift index.
PPS. If the test cases are wrong I apologize, I am not a good coder.