I am fairly new to C++ and I was wondering how I might go about converting strings such as:
Mushrooms, into
<Mu$hro0Mz!> or something very obscured by still resembled by the new characters.
I was thinking, in my uneducated position, of a table look up or a file, XML or something with a list of possible changes.
So if there was an S that needed to be replaced, the file would have: s, S, $ and 5 next to it and it would chose randomly which one to replace the S with.
What kind of method are you talking about? Use the replace function. If you want to let the user input the word, you can either ask with cin or use arguments.
It seems like I've done something wrong with the randomizing part, I'm not really sure though. It seems like the seed isn't initialized correctly, but I'll leave that to someone else.
Then you "substChar()" function would:
- lookup entry for char, using it as the index
- get length of substr string and randomly choose one char in it
- randomly change case (leave alone/toupper/tolower)
You could convert the lookup table to a std::vector which you populate from a file (XML or otherwise) later on.
To support Unicode it would probably be better with a std::map, as you'll only want to handle a limited number of the available wchars_t values. Or you could use the first char in the lookup table as a key and search for it, rather than using the char directly as an index.