Since I don't want to use anything from the com.misc package, I wanted to move away frm using BASE64Encoder in my encryption method. I decided to use the Base64 object from the org.apache.commons.codec.binary package in the Apache Commons library.
Running the switch, however, my unit tests fail. Does anyone have any suggestions on what to use instead of Base64 and BASE64Encoder or tell me what I'm doing wrong?
Original Code:
MessageDigest digest = getLocalDigest();
byte[] digested = digest.digest(data);
enc = new BASE64Encoder().encode(digested);
New Code:
MessageDigest digest = getLocalDigest();
byte[] digested = digest.digest(data);
enc = new Base64().encode(digested).toString();
Unit Test:
stringResult1 = new Encryptor().encrypt(string);
stringResult2 = new Encryptor().encrypt(string);
assertEquals("Encryption of Identical String", stringResult1, stringResult2);