나는이 코드를 YouTube 비디오에서 가져옵니다.이 코드에서 이미지를 올바르게 암호화했지만 이미지를 해독 할 수 없었습니다 .. 누구든지 나를 도울 수 있습니까 ???자바를 사용하여 이미지 암호 해독
암호화 코드
FileInputStream file = new FileInputStream("src/image/A.jpg");
FileOutputStream output = new FileOutputStream("src/image/AA.jpg");
byte j[]="12345678".getBytes();
SecretKeySpec kye = new SecretKeySpec(j,"DES");
System.out.println(kye);
Cipher enc = Cipher.getInstance("DES");
enc.init(Cipher.ENCRYPT_MODE,kye);
CipherOutputStream cos = new CipherOutputStream(output, enc);
byte[] buf = new byte[1024];
int read;
while((read=file.read(buf))!=-1){
cos.write(buf,0,read);
}
file.close();
output.flush();
cos.close();
해독 코드
FileInputStream file = new FileInputStream("src/image/AA.jpg");
FileOutputStream output = new FileOutputStream("src/image/AAA.jpg");
byte j[]="12345678".getBytes();
SecretKeySpec kye = new SecretKeySpec(j,"DES");
System.out.println(kye);
Cipher enc = Cipher.getInstance("DES");
enc.init(Cipher.DECRYPT_MODE,kye);
CipherOutputStream cos = new CipherOutputStream(output, enc);
byte[] buf = new byte[1024];
int read;
while((read=file.read(buf))!=-1){
cos.write(buf,0,read);
}
file.close();
output.flush();
cos.close();
는 그것은 relativly 이전 게시물 당신
암호를 해독 할 수없는 경우 왜 올바르게 암호화 했습니까? – Bandrami
'close()'전에 아마'flush()'해야합니다 ('flush()'할 것). –
이미지에 잘못된 이미지가 있기 때문에 문제가 있습니까? – NoughT