Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cipher cipher = Cipher.getInstance("AES");
- SecretKeySpec skey = new SecretKeySpec(DatatypeConverter.parseBase64Binary(Dispatcher.getK()), "AES");
- cipher.init(mod, skey);
- byte[] bytes = new byte[1024];
- int numBytes;
- if(mod == Cipher.ENCRYPT_MODE) {
- CipherOutputStream cos = new CipherOutputStream(outputFile, cipher);
- while ((numBytes = inputFile.read(bytes)) != -1){
- cos.write(bytes, 0, numBytes);
- }
- cos.flush();
- cos.close();
- inputFile.close();
- }
- if (mod == Cipher.DECRYPT_MODE){
- CipherInputStream cis = new CipherInputStream(inputFile, cipher);
- while ((numBytes = cis.read(bytes)) != -1){
- outputFile.write(bytes, 0, numBytes);
- }
- outputFile.flush();
- outputFile.close();
- cis.close();
- }
Add Comment
Please, Sign In to add comment