This may or may not answer your question, but it's waaay too long for a comment.
I can't speak for the actual close voters but... If I had come across this in the review queue I would have voted to close your question, and I would have used that reason. As to why: how can I possibly explain the solution in an answer of any reasonable length? Or the faulty premises inherent in the question like how you know the length of the plain text? Or do you wrongly assume that the hashed output has the same length as the plain text? What hashing function are we talking about, and how/why do you know that? How many rounds? etc. etc. How many related sub-concepts do I need to explain?
Then we get into the problems that aren't related to the actual problem but the limitations of physical resources. Assuming only lower case asciiASCII alphabet characters (no numbers, punctuation, uppercase, unicodeor Unicode) the number of possibilities for length n is n ^ 27. Adding in numbers and uppercase and punctuation takes up to... ok I stopped counting at 81. Let's just say n ^ 81. And that's without unicodeUnicode! That's a lot of data for even fairly small values of n, much less larger ones. How are you handling that? Obviously it can be done (rainbow tables are a thing), but how are you storing and querying this? To your credit you at least give nod to that in the question itself but that could be a probably still too broad question in it's own right.
I could go on, and we haven't even made it to the code yet. There's just too much going on here to fit into the space of a StackoverflowStack Overflow answer, which is why it's too broad. Any "answer" would have to punt on a number of crucial details, and/or require a level of interaction with you that amounts to the interactively teaching you the contents of multiple tutorials and even if someone were willing StackoverflowStack Overflow just isn't a good venue for that.
And don't feel too bad about it. Without experience it is often possible that you don't realize just how deep the rabbit hole goes, or how to research a given topic effectively, or how to have a good feel for what will fit in a Q&A post.
As for why you didn't get a lot of feedback on the question itself, well, look at how long this feedback is. No way this would have fit in comment(s) on the question itself.