I am facing a problem while decrypting a file.
The decryption process is too slow. The algorithm i am using is RSA public key encryption. Which is toooooo slow while decrypting the file.
I am doing the following steps ...
1) I read the encrypted data from the file
2) decrypt it and save it in a list
3) Then read the data from the list and write it back in the same file
"Step 3 is fine but decryption itself in step 2 is too slow."
public void Decryption(
String fileName) {
try {
byte[] buffer = new byte[256];
ArrayList file = new ArrayList();
InputStream in = new FileInputStream(fileName);
while ((in.read(buffer)) != -1) {
file.add(dcipher.doFinal(buffer));
System.out.println(new String((byte[]) dcipher.doFinal(buffer),"UTF8"));
}
in.close();
FileWriter fw = new FileWriter(fileName);
for (int i = 0; i < file.size(); i++) {
fw.write(new String((byte[]) file.get(i),"UTF8"));
}
fw.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Can somebody check the code and let me know if i am doing something wrong in this....