I am trying to decrypt a modified Vigenère cipher text. I am unfamiliar with Mathematica, so I need some guidance. Here is what I want:
modifiedVigenere[ciphertext_, keylength_]:= *insert code here*
Here is what I want the code to do. First, convert the ciphertext to numbers mod 26. I already have a command which will do this.
stringToNumbers[string_] := ToCharacterCode[StringReplace[ToUpperCase[string],
RegularExpression["[^A-Z]"] -> ""]] - 65
Then I want to modify the numbers based on the keylength. Let's say the string changes to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Then, let's say the keylength is 3. I want to subtract 0 from the first three entries in the list, 1 from the second three, 2 from the third three, and then 3 from the final three (in this case, only the number 10). The resulting string would look like this: {1, 2, 3, 3, 4, 5, 5, 6, 7, 7}.
I would then change the numbers back into a string with the following command:
numbersToString[list_] :=
FromCharacterCode[
Select[list, Function[x, IntegerQ[x] && x >= 0 && x <26]] + 65
]
If anyone could help me, that would be greatly appreciated.
stringToNumbersandnumbersToStringyou can also use the functionsLetterNumberandFromLetterNumber. $\endgroup$