masterbeta
Messages postés4Date d'inscriptionsamedi 5 mars 2011StatutMembreDernière intervention11 mars 2011
-
11 mars 2011 à 21:47
seb576
Messages postés43Date d'inscriptionmercredi 17 novembre 2010StatutMembreDernière intervention 3 juin 2012
-
6 mai 2011 à 15:08
//Encrypt a plain text from a file using the random 128bits AES key
public static byte[] cryptWithAES(String plainFile, byte[] secretKey, String cipherFile) {
// Write to file
FileOutputStream fOut = null;
fOut = new FileOutputStream(cipherFile);
fOut.write(encrypted_text);
fOut.close();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new RuntimeException();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
throw new RuntimeException();
} catch (InvalidKeyException e) {
e.printStackTrace();
throw new RuntimeException();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
throw new RuntimeException();
} catch (BadPaddingException e) {
e.printStackTrace();
throw new RuntimeException();
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
throw new RuntimeException();
}
catch (IOException e){
e.printStackTrace();
throw new RuntimeException();
}
return encrypted_text;
}
//Decrypt an encrypted text form a file using AES key
public static byte[] decryptInBytesWithAES(String cipherFile, byte[] secretKey, String plainFile) {