Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9040855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:05:32+00:00 2026-06-16T10:05:32+00:00

I am working on an AES 256 bit File encryption tool. The way it

  • 0

I am working on an AES 256 bit File encryption tool. The way it works now is by:

reading an entire file into a String,
encrypting the string,
deleting the old file, then outputting the encrypted String into the old File object.

This works for small Files, but if you were to try to encrypt a Large file, such as one larger than the Heap Space java has access too, you receive errors. Long story short, how can i read the file one MB at a time, as a String, encrypt that string, then write that MB to a temp file? This would allow for large files to be encrypted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:05:33+00:00Added an answer on June 16, 2026 at 10:05 am

    No need for temp files. Just use File Streams (FileInputStream and FileOutputStream). Streaming I/O was exactly created for processing long files in chunks. You can use FileReader/Writer if you want to read/write strings. There is an example:

      public void decrypt(File in, File out) throws IOException, InvalidKeyException {
        aesCipher.init(Cipher.DECRYPT_MODE, aeskeySpec);
        CipherInputStream is = new CipherInputStream(new FileInputStream(in), aesCipher);
        FileOutputStream os = new FileOutputStream(out);
    
        int i;
        byte[] b = new byte[1024];
        while((i=is.read(b))!=-1) {
                os.write(b, 0, i);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, now I have coded for an implementation of AES-128 :) It is working
I've been trying to get AES encryption and decryption working for some time in
In my project i am working on AES encryption and Decryption.i have used this
I'm implementing encryption / decryption using Java Cipher and AES. Everything is working well
I'm working with a listview control which saves the data using AES encryption to
I'm working a small project, using AES encryption and wanted to use it in
I would like to create an IV encryption with aes 256 and cbc pkcs7
I am working on a project that requires appending to a AES/CTR encrypted file.
I've managed to get AES/Rijndael [256bit key / 128bit block size] symmetric encryption working:
I am trying to encrypt a string with AES 128 encryption, using CBC mode,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.