how to encrypt file with AES in Java?

Discussion in 'Java' started by JTL.zheng, Jan 6, 2007.

  1. JTL.zheng

    JTL.zheng Guest

    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
     
    JTL.zheng, Jan 6, 2007
    #1
    1. Advertising

  2. JTL.zheng wrote:
    > 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
     
    =?UTF-8?B?QXJuZSBWYWpow7hq?=, Jan 6, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bsdmike
    Replies:
    0
    Views:
    645
    bsdmike
    Feb 18, 2006
  2. horst
    Replies:
    1
    Views:
    1,014
    Mike Hewson
    Jan 5, 2005
  3. JTL.zheng
    Replies:
    3
    Views:
    8,836
    JTL.zheng
    Jan 11, 2007
  4. Nate Wiger

    New AES gem available -- fast-aes

    Nate Wiger, Jan 20, 2010, in forum: Ruby
    Replies:
    3
    Views:
    217
    Pål Bergström
    Jul 1, 2010
  5. http://ejobseek.com

    Encrypt in Perl, De-encrypt in Javascript

    http://ejobseek.com, Sep 1, 2003, in forum: Perl Misc
    Replies:
    3
    Views:
    303
    James Willmore
    Sep 1, 2003
Loading...

Share This Page