Closed abbi-gehl closed 7 months ago
Code written to populate a c++ map that does the same functionality as the Key Value pairs.
Should look into how the map is indexed, and how it will be best translated over to MASM.
My initial thought is maybe using the default alphabet array to index the Map, and indexing that array to get the corresponding character in the alphabet so we can just worry about integers. We could instead increment say an ASKEY value by whatever the difference between letters is, but that may prove unnecessarily complicated. We may just be able to increment the map by an integer, I should really just look at the documentation.
https://cplusplus.com/reference/map/map/begin/
Seems like we can iterate through it in c++ using an iterator, that would function similarly to an integer.
for (std::map<char,int>::iterator it=mymap.begin(); it!=mymap.end(); ++it)
std::cout << it->first << " => " << it->second << '\n';
Instead of adding to an integer, we can call a function that will increment the iterator itself.
https://cplusplus.com/reference/map/map/count/ EVEN BETTER!
for (c='a'; c<'h'; c++)
{
std::cout << c;
if (mymap.count(c)>0)
std::cout << " is an element of mymap.\n";
else
std::cout << " is not an element of mymap.\n";
}
We can just increment a c++ variable that is a character, starting with 'A' and just incrementing until 'Z'. The only thing we need now is to handle looping back to 'A' from 'Z'.
WOW
Creating the first working rotor would be a good first step in the rotor system.
A way to do this could be to create a 26-element array that stores <Key, Value> pairs.
Every time a new character goes through the rotor, we should increment the rotor by looking at the next element.