Quote Originally Posted by katy_price View Post
sorry what do you mean by this? do i have to change something in the code.
I don't think you should need to change something in the code. (But maybe something actually got changed on the program's way to you and you may need to revert that.) As I already said above, that shouldn't happen when the program is invoked without command line parameters. Or are you actually invoking it with some parameters when that happens? If so, please tell me what they are, as exact as possible, so I can debug that problem myself. I feel obliged to correct that bug if it is one, since it's my program.

i dont actually understand this program. how do i decrypt the file. plus i get the exception so really i can't use it.
I already posted a command line to encrypt a file in post #12. Maybe you got confused by "test.txt.encrypted"? That's just a file name with an unusually long file name extension. Assuming .cry as the extension for the encrypted file (which is non-standard as well but looks more familiar), the command line to encrypt the file test.txt would look like this:

Code:
cryptex1 encrypt My123Password test.txt test.cry
To decryt the file again, you would use something like:

Code:
cryptex1 decrypt My123Password test.cry test_decrypted.txt
Clear now?

i think i would like to use this one though because i understand what its doing, i just don't know how to implement it into my program and make it work the way i need it to.
I really don't like that idea but if you insist on it... I assume your app is no real-life app anyway.

i want to separate the encrypt and decrypt sections, i want to put the encrypt code in a separate program and use the decrypt code in my actuall login program.
The algorithm used in that program uses some sort of "built-in key" that is the same for both encryption and decryption. But beyond that, what makes up a symmetric encryption, this algorithm also uses the identical program code for both encryption and decryption. Therefore it can be called something like a "super-symmetrical encryption" but that term doesn't really exist.

i dont know how to change the code so it encrytps and decrypts the whole text in a file.
This algorithm is used much the same like the algorithm we already discussed in our earlier thread. You just use a binary NOT instead of addition and subtraction for both encryption and decryption.

To apply the algorithm to an entire file it's best to see the data as a sequence of bytes instead of a string, i.e. a binary file rather than a text file. I usually don't recommend that, but if the files are not too large you can make your life easier by reading the entire file into a single array<Byte>, apply the binary NOT to each and every single byte and finally write it back. That's all.