ghvapmtpysbrqiurmthxdgaya

Bob is using a Cardan Grille cipher and leaves a secret message for Alice. He is using a mask of X_X__XX__X_XX_X_X__X_X__X and has a cipher…

Girolamo Cardano

ghvapmtpysbrqiurmthxdgaya

Bob is using a Cardan Grille cipher and leaves a secret message for Alice. He is using a mask of X_X__XX__X_XX_X_X__X_X__X and has a cipher of ghvapmtpysbrqiurmthxdgaya. Can you find the secret message?

Cardan Grille

The Cardan Grille cipher is named after Girolamo Cardano, who used in the 16th Century to write secret messages. It uses a grid to reveal a secret message:

Ref [here]

In this way, Bob and Alice would share a secret mask that would reveal the secret message. Bob starts with his message and lays down the mask. Next, he will remove the mask, and fill-in the rest of the words with random letters. When Alice receives the cipher message, she will simply apply the secret mask to reveal the message.

Example

In this case, we are using the Cardan Grille cipher, and where Bob and Alice will share a cipher mask. With this, an “X” will mean that Bob will pick a random letter, and a “_” will take the next letter in the secret message. In this case, we get [here]:

The basic coding in C# is [here]:

public static (string, string) getCardan(string s, string mask)
{
string chars = "abcdefghijklmnopqrstuvwxyz";
var rnd = new System.Random();
mask = mask.ToUpper();
while (countOccurences("_", mask) <= s.Length)
{
mask = mask + "_";
}

s = s.ToLower();
string rtn = "";
int i = 0;
int j = 0;
foreach (char ch in mask)
{
if (mask[i] == 'X') rtn = rtn + chars[rnd.Next(26)];
else
{
if (j >= s.Length) break;
rtn = rtn + s[j];
j++;
}
i++;

}
return (rtn, mask.Substring(0, i));
}

Go generate your own cipher here:

https://asecuritysite.com/ctf/ctf_cardan

Or take 117 cipher challenges:

https://asecuritysite.com/challenges/ctf