Hi everyone,
I've tried a lot of way but none of them works. What I'm trying to do is I'm trying to encrypt a string and store it to a file, then read that encryption and decrypt it so my program can use that string again. The storage is just using a FileOutputStream and I'm reading using FileInputStream, I can write it fine, but after I'm done reading the file and try to decrypt it, it give me javax.crypto.BadPaddingException
Here's a snippet of my code
FileInputStream fis = new FileInputStream(path
+"\\dat" + i + ".txt");
Scanner sc = new Scanner(fis);
String curr = "";
if (sc.hasNextLine())
curr = sc.nextLine();
while(sc.hasNextLine())
{
curr += '\n' + sc.nextLine();
}
System.out.println("Curr is: " + new String(curr));
data[i] = new String(gwc.decrypt(curr));
sc.close();
I've done the try catch too, i just ommited it for simplicity
Thank you in advance