Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.nio.file.Files;
- import java.nio.file.Paths;
- import javax.crypto.SecretKey;
- import javax.crypto.spec.SecretKeySpec;
- import javax.crypto.Cipher;
- import java.io.InputStream;
- import javax.crypto.CipherInputStream;
- public class Huahua {
- public static void main(String...args) throws Exception {
- // pegue a chave
- byte[]sKey=Files.readAllBytes(Paths.get("secret.key"));
- SecretKey key = new SecretKeySpec(sKey, "AES");
- Cipher cipher = Cipher.getInstance("AES");
- cipher.init(Cipher.DECRYPT_MODE, key);
- // pegue a mensagem secreta
- InputStream in = Files.newInputStream(Paths.get("quanto-tem-no-cartao.txt"));
- InputStream cin = new CipherInputStream(in, cipher);
- // jogue num outro arquivo
- Files.copy(cin,Paths.get("quanto-tem-no-cartao-decrypt.txt"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement