Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.matthi.decrypt;
- import java.io.*;
- import javax.swing.JFileChooser;
- public class App
- {
- public static void main(String[] args)
- throws Exception
- {
- JFileChooser chooser = new JFileChooser();
- chooser.setDialogTitle("Verschlüsselte Datei wählen...");
- chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
- if(chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
- {
- System.exit(1);
- }
- File file = chooser.getSelectedFile();
- final byte[] key = new byte[4096];
- App.class.getResourceAsStream("/decrypt.key").read(key);
- InputStream source = new BufferedInputStream(new FileInputStream(file));
- OutputStream target = new BufferedOutputStream(new FileOutputStream(targetName(file)));
- int pos = 0;
- while(source.available() > 0)
- {
- if(pos < 4096)
- {
- target.write(source.read() ^ key[pos]);
- pos++;
- }
- else
- {
- target.write(source.read());
- }
- }
- target.flush();
- target.close();
- source.close();
- }
- private static String targetName(File file)
- {
- return file.getParent() + File.separator + file.getName().substring(7, file.getName().length() - 5);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement