JamesCherrill
... trying to help
8,501 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
OK, so is this a question, or a code snippet, or what?
JamesCherrill
... trying to help
8,501 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
Try testing the code using a very simple input of "ABCDE"
Look at the encrypted file and see if it was correctly encrypted.
Then decrypt it and see what the output is.
This simple test should allow you to easily see the problem.
If you need help with this, post the input String, the encrypted String and the decrypted String.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
That's good. Now try for all the letters A-Z
doesn't for the a file with words.
What letters does it fail on?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What was the value of the key for that test?
A suggestion for testing:
Create a testing class with a main() method that sets the values for the files and the key
and calls the encryptor() and decryptor() methods. That will make testing much easier and remove the changing of the key's value. Then when you find what letters are not being correctly enc/dec you can make a file with just those letters and debug the code by adding lots of println statements to show what the code is doing.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Create a testing class with a main() method that sets the values for the files and the key
and calls the encryptor() and decryptor() methods.
What part don't you understand? Since the methods are static you can call them without creating an instance of the classes. For example:
Decrypt.decrypter (InFileName, key, OutFileName);
Define the 3 variables and give them values in the main() method of the testing class.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
I don't think there is an easier way to test the two methods than calling the two methods from the main() method of a special testing class. It saves the tester from having to run two separate programs and answer prompts from each program and allows the setting of the key's value that is being used to encrypt and decrypt the file.
Which part of the following are you having problems with?
1)Create a testing class
2)with a main() method
3)that sets the values for the files and the key: three Strings with file names and an int
4)and calls the encryptor() metyhod
5)and calls the decryptor() method: Decrypt.decrypter (InFileName, key, OutFileName);
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16