Trouble with class functions, c++
Giothecoder (0)


I am just having trouble getting the functions of encrypt and decrypt to work
at first if I just set the string (stream) to the return object with a = it would work
for the encrypt function but not the decrypt function. Now neither are working!
I suggest if you are just now looking at this post to still read the background info
I made an encryption class containing a key and a group of cipher alphabets with two functions: one to encrypt and one to decrypt.

I input my cipher alphabet seed thing I input my key, every thing is going fine, and then, right after I input my message that I’m going to encrypt, my program just crashes with a return of -1 I think it was.
I did some tests and I am relatively certain that my encrypt and decrypt functions are making the program crash.

Here’s the link to the code...


The cipher alphabet is a polyalphabetic cipher which is basically a series of monoalphabetic ciphers alphabets.
A monoalphabetic cipher being something like
Q = A, W = B,E = C,etc.

When using a polyalphabetic cipher one must also use a key. The key simply tells you which cipher alphabet to use from the group of monoalphabetic ciphers
I First input a monoalphabetic cipher, which I use to make a polyalphabetic cipher by shifting it over for each one in the group, and then I input a key, which tells me how to encrypt the message using the polyalphabetic cipher. Lastly I input the message that I then encrypt, letter by letter.

If you have ABSOLUTELY ANY questions about what I have said, comment. If you have an answer to my question please for gs sake comment I’m dying here.
Thanks :)

You are viewing a single comment. View All
SPQR (333)

the std::bad_alloc can be solved by commenting out std::cin >> a; on line 68.

Giothecoder (0)

@SPQR thanks but its still just giving me the same error as before, same place even