I am currently throwing an obfuscation program for school homework together. I am trying to make the program read a file and then create a new file that replaces each letter in the file with some a corresponding value that I pull from a HashMap
. I set up a whole bunch of keys and values, but later in the process of writing the new file I try to check if the map contains a key before appending to the new String
. The characters that are checked are in fact in the file that I am reading from to test, and the file is read correctly. Yet it fails with the encryptionDict.containsKey()
(my hashmap) method.
I hope some Java expert can help me figure this out! I'm pretty clueless, I'm more of a C and D guy. The only thought that struck me was that it would be something like with Strings where "foo" != "foo"
. But chars aren't objects.
The code is in a pastebin below, the key parts to look at is the class constructor, the method encrypt, and the method initDictionary
, also can someone tell me why HashMap<char, String>
is invalid, is it because I have to use an object?
The code: http://pastebin.com/NcHTHPfw