Cipher CTF Challenge Generator (Progressive Caesar Cipher)Press the blue button to regenerate a Progressive Caesar cipher challenge. The Progressive Caesar cipher takes the initial Caeser shift, and then adds one onto the shift for each letter. |
Coding
The Progressive Caesar cipher takes the initial Caeser shift, and then adds one onto the shift for each letter. For example, "brspjivzn" with a key of "1" becomes:
applecore brspjivzn
and where 'a' is shifted by 1 to get a 'b', and 'p' shifted by 2 gives an 'r'.
The basic coding in C# is:
public static string getProgressive(string s, string key) { s = s.ToLower(); string rtn = ""; var shift = Convert.ToInt32(key) % 26; foreach (char ch in s) { try { if (ch == ' ') rtn = rtn + " "; else if (ch >= 'a' && ch <= 'z') { if (shift >= 0) { rtn = rtn + (char)((((int)ch - (int)'a' + shift) % 26) + (int)'a'); shift++; } } } catch (Exception ex) { } } return (rtn); }