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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:30:12+00:00 2026-05-18T02:30:12+00:00

I am doing a project in ‘Steganography’ in which I want to encrypt the

  • 0

I am doing a project in ‘Steganography’ in which I want to encrypt the contents of file using ‘Blowfish’ algorithm and then want to embed the encrypted text in the image and do the reverse procedure for extracting the image.
The ‘update’ method from class ‘Cipher’ encrypts only some no. of bytes but, here I want all the bytes(encrypted contents) of the file in only one array. Same is the case with ‘update’ method in decryption. This array later will be passed to a method in which I embed the text in the image and extract when required.So what can be the better approach towards this problem?
Thank you.

  • 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-05-18T02:30:12+00:00Added an answer on May 18, 2026 at 2:30 am

    Most ciphers are streaming ciphers. They can take blobs of data and stream out results as it encrypt/decrypts them. The Java Cipher class works this way. You call update(..) with a block of data, and it returns a block of encrypted data. When you reach the end of your input data, you call the final(…) method.

    Now, if you wish to accumulate all of your data in to a single binary buffer, and encrypt it all at once, that works fine also. But in the end, either way works, the cipher doesn’t care if it encrypts 1 byte at a time or 1MB at a time.

    If you simply want to know how to append byte arrays, you simply create a new byte array that has a length equal to the sum of the sizes of the arrays you wish to append, then use System.arraycopy to move copy the original arrays.

    byte[] newbuf = new byte[oldbuf1.length + oldbuf2.length];
    System.arraycopy(oldbuf1, 0, newbuf, 0, oldbuf1.length);
    System.arraycopy(oldbuf2, 0, newbuf, oldbuf1.length, oldbuf2.length);
    

    If you’re going to do that a lot, and you have the memory to spare, it’s better to accumulate your chunks of data in to disparate byte buffers, stuff them in a List, and then do your final merge just once.

    int sum = 0;
    for(byte[] ba : arraysList) {
        sum = sum + ba.length;
    }
    byte[] newbuf = new byte[sum];
    int curpos = 0;
    for(byte[] ba : arraysList) {
        System.arraycopy(ba, 0, newbuf, curpos, ba.length);
        curpos = curpos + ba.length;
    }
    

    (Code not tested, should work, don’t think there’s any 1-offs in there.)

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

Sidebar

Related Questions

I am doing a project which will finally print a pdf file or doc
I'm doing project on object detection using javacv in that I went through couple
I am doing project in cakephp . I want to write below query in
Im doing a project where Alice and Bob send each other messages using the
I am doing project in vb.net using ms access database I used one query
I am doing a project in ftp,which will do multiple uploads,and the process i
I'm doing Project Euler #22: Using names.txt (right click and 'Save Link/Target As...'), a
I am doing Project Euler Problem 15 . I used the right algorithm, but
I am doing project using Lucen library in here I need to build query
I am doing a project in which as per number getting by GET method,

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.