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 8482611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:51:57+00:00 2026-06-10T19:51:57+00:00

For partial file upload and encryption i’d like to read chunks (example: 10MB) from

  • 0

For partial file upload and encryption i’d like to read chunks (example: 10MB) from a large file (example: 100MB), encrypt the chunk with AES256 and upload the chunk to the server.
On the server the chunks are joined together to one big file (which then should represent the complete encrypted file).

I’d like to avoid a full encryption of the file (example: 100MB!) before taking out chunks and sending them to the server (CPU overhead, because i would then first need to copy the whole file and do AES256 over the whole file).

I tried the following (example for a 16MB File = 2 Chunks = 1*10MB + 1*6MB)

1st chunk is ~10MB, ensured then the chunksize is a multiple of 16 (AES_BLOCK_SIZE)

EVP_CIPHER_CTX e_ctx;
EVP_CIPHER_CTX_init(&e_ctx);
EVP_EncryptInit_ex(&e_ctx, EVP_aes_256_cbc(), NULL, key, iv);
EVP_EncryptUpdate(&e_ctx, enc_data, &outlen, unenc_data, chunksize_to_load_from_file_unencrypted);

During the 1st chunk, i do not call EVP_EncryptFinal_ex() because the encryption is not finished yet (maybe this is the problem?).

2nd chunk is ~6MB, there i encrypt the rest of the data offset from &outlen above

EVP_CIPHER_CTX e_ctx;
EVP_CIPHER_CTX_init(&e_ctx);
EVP_EncryptInit_ex(&e_ctx, EVP_aes_256_cbc(), NULL, key, iv);
EVP_EncryptUpdate(&e_ctx, enc_data, &outlen, unenc_data, chunksize_to_load_from_file_unencrypted);
EVP_EncryptFinal_ex(&e_ctx, enc_data+outlen, &final_length);

On the server the two file-parts get’s joined.
I then can decrypt the file “successfully”, same size of the unencrypted file. But at offset ~10MB, some bytes are different (16 Bytes! = AES_BLOCK_SIZE)

Any idea? Could that be the padding? Is that not only at the end?
Does EVP_EncryptFinal_ex act different when not pass through the whole file through EVP_EncryptUpdate?

How can i do transmission of encrypted partial-file-chunk and join them on the server to get a proper encrypted file?

Thanks!

  • 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-10T19:51:58+00:00Added an answer on June 10, 2026 at 7:51 pm

    You are using the wrong initialization vector for the second chunk. With CBC, the iv of the subsequent encryption should be the last 16 bytes of the previous ciphertext. That way, just concatenating the encrypted parts gives the encryption of the whole.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (partial) qmake project file like this: TEMPLATE=lib TARGET=whatever SOURCES=whatever.cpp HEADERS=whatever.h This
Partial output from git blame <file> : ... d6182477 (<author> 2012-06-22 09:44:02 -0400 239)
So I have ajax file upload partial (using Jquery Form plugin), it's working perfectly,
I'm trying to make a multi-file upload. with help from this blog , but
I have download the code for OpenFileDialog (File Upload function) from Silverlight tutorials website.
In a partial view I load a javascript file like this : <script src=@Url.Content(~/Scripts/Testing.js)
I have an entity called File, I created a partial class with a property
I have the following inide my Page_Load on an aspx.cs file: public abstract partial
How to call Html.Partial() method from controller or some other method in external class
I have a file upload button on my MVC view. After the file is

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.