Im writting a program that allows the user to create a password that is encrypted to a text file. So far, I can create a password and guess it correcetly/incorrectly, but instead of encrypting the password to the text file, it keeps writting the actual password to the file.
I have tried searching for other methods, but I haven't found anyone making a password maker/guesser like this. How can I have my password encrypted in the text file, and reverse encrypted back into the code to be guessed?
Instead of just writing the string to the file like you do, encrypt in first, then write the encrypted string. Then, decrypt the string after reading it in, instead of just assuming the string in the file is the password.
You should go look up some encryption method online that you want to implement, preferably something simple like a shift cipher. Then just use that method before writing/after reading the string to/from the file.
I am using a shift cipher of 13, but I'm having trouble changing a string into individual characters which I can static_cast to find their integer values to make the change. I don't know of any other ways to change the values of the characters in the password so that the password can be encrypted.
You can modify an individual character of a string very easily, like so: str[i] += 5; // adds 5 to the ASCII value of the i-th character of str
In your actual code, you'll want to make sure you actually "wrap" around the alphabet, so adding 13 to 'z' doesn't give you '_'.