Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. dy}uƒ0^u‡0b}q~K‹lvAlv‚}q~lv€‚Blvsxq‚ƒu„B0c‰}r|K‹lvBlvƒ‡yƒƒlv€‚Blvsxq‚ƒu„@0Q‚yq|K‹lvClv‚}q~lv€‚Blvsxq‚ƒu„@0yru‚q„y~0cu‚yv‹l:lvq|„0dy}uƒ0^u‡0b}q~K‹lvDlvƒ‡yƒƒlv€‚Blvsxq‚ƒu„@0yru‚q„y~0cq~ƒ‹l:lvq|„0Q‚yq|K‹lvElv‚}q~lv€‚@lvsxq‚ƒu„ABH0dy}uƒ0^u‡0b}q~K‹lvFlv~y|l
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.File;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileReader;
  7. import java.io.FileWriter;
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10.  
  11. public class Run {
  12. private static FileWriter fr;
  13. static String b;
  14. private static BufferedReader br;
  15.  
  16. public static void main(String[] args) throws IOException {
  17.  
  18. // encrypted file
  19. File enc_f = new File("caesar.rtf.enc");
  20. //decrypted file
  21. File dec_f = new File("caesar.rtf.dec");
  22.  
  23. // init variables
  24. String text_enc = new String();
  25. String text_dec = new String();
  26.  
  27. // read file
  28. br = new BufferedReader(new FileReader(enc_f));
  29. for (String line; (line = br.readLine()) != null; text_enc += line);
  30. char[] stringToCharArray = text_enc.toCharArray();
  31.  
  32. // parse file and convert string to char
  33. for (int shift = 0; shift < 257; shift++) {
  34.  
  35. for (char output : stringToCharArray) {
  36.  
  37. // convert ascii to int
  38. int ascii = (int) output;
  39.  
  40. // shift
  41. ascii = ascii + shift;
  42. ascii = ascii % 256;
  43.  
  44. // convert back to ascii
  45. char chTemp = (char) ascii;
  46. text_dec += chTemp;
  47.  
  48. }
  49.  
  50. // visual representation
  51. text_dec += System.lineSeparator();
  52. text_dec += System.lineSeparator();
  53. text_dec += shift;
  54. text_dec += System.lineSeparator();
  55. System.out.println(shift);
  56.  
  57. // write decrypted file
  58. fr = new FileWriter(dec_f);
  59. fr.write(text_dec);
  60.  
  61. }
  62. fr.close();
  63. }
  64. }
  65.  
  66. Timeí Neí Roman;ííf1fíomanfííí2fchaííeí2 Símbol;ííf2fííiíífííí2fchaííeí0 Aíial;ííf3fíomanfííí2fchaííeí0 Libeíaíion Seíifí*falí Timeí Neí Romaní;ííf4fííiíífííí2fchaííeí0 Libeíaíion Saníí*falí Aíialí;ííf5fíomanfííí0fchaííeí128 Timeí Neí Roman;ííf6fnil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement