Advertisement
sombriks

Untitled

Oct 5th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.79 KB | None | 0 0
  1.  
  2. import java.nio.file.Files;
  3. import java.nio.file.Paths;
  4.  
  5. import javax.crypto.SecretKey;
  6. import javax.crypto.spec.SecretKeySpec;
  7. import javax.crypto.Cipher;
  8.  
  9. import java.io.InputStream;
  10. import javax.crypto.CipherInputStream;
  11.  
  12.  
  13. public class Huahua {
  14.  
  15.     public static void main(String...args) throws Exception {
  16.         // pegue a chave
  17.         byte[]sKey=Files.readAllBytes(Paths.get("secret.key"));
  18.         SecretKey key = new SecretKeySpec(sKey, "AES");
  19.         Cipher cipher = Cipher.getInstance("AES");
  20.         cipher.init(Cipher.DECRYPT_MODE, key);
  21.         // pegue a mensagem secreta
  22.         InputStream in = Files.newInputStream(Paths.get("quanto-tem-no-cartao.txt"));
  23.         InputStream cin = new CipherInputStream(in, cipher);
  24.         // jogue num outro arquivo
  25.         Files.copy(cin,Paths.get("quanto-tem-no-cartao-decrypt.txt"));
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement