Affine Cipher
I'm trying to write a brute force function that decrypts text that's been encrypted with an affine cipher, i.e. plaintext = (ciphertext * multiplier + adder) mod 26. So far here's what I have:
Code:
void decrypt(string str1) |
My guess is that str2 is not big enough for the "str2[i]" indexing that you are doing and this is overwriting the where mult and add are stored. Try setting the str2 length with resize() :
Code:
int add = 0; |
Str1 and Str2?
You pass in str1, but then where does str2 come from? You also make length equal str1.length() but don't use it?
|
Here's the whole function including my suggested modification and some additional comments to address your concerns:
Code:
void decrypt(string str1) |
All times are GMT -5. The time now is 10:36 AM. |