public String add(String name, String value) {
try {
cipher.init(Cipher.ENCRYPT_MODE, key);
final sun.misc.BASE64Encoder base64encoder = new BASE64Encoder();
// I think that we should pull out everything from the file, decrypt it,
// append the new text to it, then encrypt it all and save it
final String readText = readText();
//final String fullText = readText() + name + "\t" + value + "\n";
// ENCODE plainTextPassword String
byte[] cleartext = base64encoder.encode((readText + name + "\t" + value + "\n").getBytes("UTF8")).getBytes("UTF8");
// String junk = "";
// while(cleartext.length % 8 != 0){
// junk += "-";
// cleartext = (readText + name + "\t" + value + junk + "\n").getBytes("UTF8");
// }
for(byte b : cleartext){
System.out.println("-" + b + "-");
}
System.out.println("length of clearText: " + cleartext.length);
//byte[] bIn = cipher.doFinal(fullText.getBytes("UTF-8"));
final String encrypedPwd = base64encoder.encode(cipher.doFinal(cleartext));
// now you can store it
writeText(encrypedPwd);
return encrypedPwd;