good day all,
please I would be most grateful if anyone could help me with the code for a C# program that can read ordinary English text from a text file and encode it by replacing each text with the 13th next letter in the alphabet for example "Ang Rus" becomes "Nat Ehf" using the CryptoStream class i.e DES and TripleDES after which the encoded text is saved to a text file which can also be decoded also be decoded back to ordinary English using the same code.Thank you all
this is what i have been able to do so far, but the problem i am faced with is that the loop does not seem to see all the "if" and else "if" statements it just executes the "else" statement at the end of the loop so all it ends up printing is the "from_file" therefore the text in the original text file "MyFile.txt" is exactly what is rewritten to the new file "MyFile1.txt" please i need help.
this is the source code:
Joined: Oct 13, 2005
What a dreadful bank of "if"s. Are you really adding a constant amount to each char? You realise that at least in Java™, a char is an integer, so you can do arithmetic with it; you can add numbers, use the % operator for remainders, and add the remainder to 'a'. I am not sure whether it works in C#, but you should try it with some simple applications and see what happens.
Beware; if you get 'a' == 1 and add 1 to 'a' you will get 'b', so you may need an additional - 1. You may need to cast the result back to a (char) or use a method of Convert.