so i am loading a file that has some encrypted text in it, it uses a custom character table, how can i load it from an external file or put the character table in the code ?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Start by going over the file and counting the lines so you can allocate an array. You could just use a list here but arrays have much better performance and you have a significant amount of items which you’ll have to loop over a lot (once for each encoded char in the file) so I think you should use an array instead.
Now we’re going to allocate and array of tuples;
After that we’ll loop over the file again adding each key-value pair as a tuple.
I’ve given you a lot of code although this may take a little tinkering to make work. I didn’t both to write the second loop in a compiler and I’m too lazy to look up things like
System.String.Trimand make sure I’m using it correctly. I’ll leave those things to you. This has the core logic to do it. If you want to instead use a list move the logic inside of the for loop into the while loop where I count the lines.Do decode the file you’re reading you’ll have to loop over this array and compare the keys or values until you have a match.
One other thing – your array of tuples is going to have some empty indexes (the array is of length
lineswhile there are actuallylines - comments + blankLinesin the file). You’ll need some check to make sure you’re not accessing these indexes when you try to match characters. Alternatively, you could enhance the file reading so it doesn’t count blank lines or comments or remove those lines from the file you read from. The best solution would be to enhance the file reading but that’s also the most work.