Currently, I'm working on creating matrices for cryptography projects. However, I'm having an issue when trying to pass a matrix to a function without having the size for the rows and columns.
Summary of code:
In main, I create an instance of a Cipher class, I'm allowed to get an input file (plaintext) and a key (key is used for enc/decryption).
Then, in Cipher.cpp
, I do the blocks for the class functions. For this question, I'll focus on encryption function.
Inside of it, I initialized a char matrix[plaintext.size()][keySize]
.
Now, because of modularity, I want to pass this matrix by reference to a function that generates the matrix. This is the issue, I cannot pass the matrix with two variables (plaintextSize
, keySize
), I can only pass it with constant values (e.g char (&matrix)[5][5]
).
I've also tried passing like char* matrix
, but that obviously doesn't work. This issue leaves me with an encryption function that does two different things: generating the matrix and doing the actual encryption, which is something I don't want.
Any help will be appreciated it.