how to encrypt file with AES in Java?

J

JTL.zheng

Could you give me an example about how to encrypt file with AES in
Java?

something like:
public static boolean encrypt(String key, File fileIn, File fileOut);

Thank you very much
 
G

Guest

JTL.zheng said:
Could you give me an example about how to encrypt file with AES in
Java?

something like:
public static boolean encrypt(String key, File fileIn, File fileOut);

If you setup as:

Cipher aes = Cipher.getInstance("AES");
aes.init(mode, new SecretKeySpec(key.getBytes("UTF-8"), "AES"));

then you can encrypt with:
b2 = aes.update(b, 0, n);
and:
b2 = aes.doFinal(b, 0, n);

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top