Contoh Program Vigenere Cipher
How would I go about modifying this code to accept input from the user rather than using a predetermined string? Specifically, I need the program to require exactly two command line arguments. The first will either be the code '-e' or '-d' to indicate encoding or decoding of a message (this determines adding or subtracting you shift values) and the second parameter will be a single word that will be the keyword that you use for the encryption or decryption.
Update
Thanks to your input and a few other sources I have re-developed my main code as is shown below. I am having trouble getting the program to decrypt and encrypt strings properly and I am not sure if the error is somewhere in the code itself, or operator error. Does anything look out of the ordinary here and how could I get this code functional to where it can encrypt or decrypt given user input?
2 Answers
If you want command line arguments, you'll need to change the prototype of your main function a little bit and use the standard argv array:
Minimal effort made for a quick example, code probably works, e&oe, caveat emptor, etc.
Of course, you'd really be best off using a proper command line argument parser, like getopt, and you'll still need some way to supply the plaintext for encryption or ciphertext for decription, but that's left as an exercise for the reader. Reading from stdin by using std::cin is one way of doing so, for example.
But a late-stage cancer identification cuts the celebration brief, placing him in a challenging place of dedication. Deadpool download torrent kickass. Falling in love with Vanessa, Wade finds an actual link in his lonely universe, making big plans for your future.
Use cin to accept input from the user and input it into a string. Parse the string to obtain the -e/-d flags and the keyword. If the input is not what you want, prompt the user to try again.
Not the answer you're looking for? Browse other questions tagged c++encryptionvigenere or ask your own question.
Comments are closed.