1. Home >
  2. Apps >
  3. Groups >

Java image encryption resolve the issue

Question asked by hare singh nayak in #Hacking and Security on Mar 6, 2013
hare singh nayak
hare singh nayak · Mar 6, 2013
Rank D2 - MASTER
hay guys this code is written by me for image encryption the data is written in file but not preview.....
help it's urgent.
thanks in advance.

package binaryfilehandling;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
*
* @author WLAN_04
*/
public class Main {
/**
* param args the command line arguments
*/
public static void main(String[] args) {
String strSourceFile="C://hare//Sunset.jpg";
String strDestinationFile="C://hare//aaa.jpg";
String a;
int c;
try
{
//create FileInputStream object for source file
FileInputStream fin = new FileInputStream(strSourceFile);
//create FileOutputStream object for destination file
FileOutputStream fout = new FileOutputStream(strDestinationFile);
byte[] b = new byte[10];
byte[] b1 = new byte[10];
int noOfBytes = 0;
System.out.println("Copying file using streams");
//read bytes from source file and write to destination file
while( (noOfBytes = fin.read(b)) != -1 )
{
System.out.println(b.length);
int j=0;
for(int i=b.length-1;i>=0;i--){
b1[j]=b;
// System.out.println(b1);
//System.out.println(b);
j++;
}

fout.write(b1, 0 , noOfBytes);


}

System.out.println("File copied!");
//close the streams
fin.close();
fout.close();
}
catch(FileNotFoundException fnf)
{
System.out.println("Specified file not found :" + fnf);
}
catch(IOException ioe)
{
System.out.println("Error while copying file :" + ioe);
}

// TODO code application logic here
}
}
Posted in: #Hacking and Security
rahul69
rahul69 · Mar 6, 2013
Rank B2 - LEADER
Could u tell in detail which preview are you talking about, the code seems fine, but I think, in line:
for(int i=b.length-1;i>=0;i--){
b1[j]=b;
It should be b1[j]=b[j];
hare singh nayak
hare singh nayak · Mar 6, 2013
Rank D2 - MASTER
rahul69
Could u tell in detail which preview are you talking about, the code seems fine, but I think, in line:
for(int i=b.length-1;i>=0;i--){
b1[j]=b;
It should be b1[j]=b[j];


yes you are are right

It should be b1[j]=b[j];

but still
i am not able to preview the encrypted image

You must log-in or sign-up to reply to this post.

Click to Log-In or Sign-Up