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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:06:46+00:00 2026-06-04T02:06:46+00:00

Hello i am searching free api or some easy code to encrypt and decrypt

  • 0

Hello i am searching free api or some easy code to encrypt and decrypt pdf files. Encryption should be done on downloading file from a stream:

            while ((bufferLength = inputStream.read(buffer)) > 0) {

                /*
                 * Writes bufferLength characters starting at 0 in buffer to the target
                 * 
                 * buffer the non-null character array to write. 0 the index
                 * of the first character in buffer to write. bufferLength the maximum
                 * number of characters to write.
                 */
                fileOutput.write(buffer, 0, bufferLength);


            }

And decrypt when need to open with pdf reader. Maybe there are some info, code or free Api for this ?
Someone had done something like this ?

I found myself some code and api. But nothing good for now.

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-04T02:06:47+00:00Added an answer on June 4, 2026 at 2:06 am

    You can try like this using CipherOuputStream and CipherInputStream:

    byte[] buf = new byte[1024];
    

    Encryption:

    public void encrypt(InputStream in, OutputStream out) {
        try {
            // Bytes written to out will be encrypted
            out = new CipherOutputStream(out, ecipher);
    
            // Read in the cleartext bytes and write to out to encrypt
            int numRead = 0;
            while ((numRead = in.read(buf)) >= 0) {
                out.write(buf, 0, numRead);
            }
            out.close();
        } catch (java.io.IOException e) {
        }
    }
    

    Decryption:

    public void decrypt(InputStream in, OutputStream out) {
        try {
            // Bytes read from in will be decrypted
            in = new CipherInputStream(in, dcipher);
    
            // Read in the decrypted bytes and write the cleartext to out
            int numRead = 0;
            while ((numRead = in.read(buf)) >= 0) {
                out.write(buf, 0, numRead);
            }
            out.close();
        } catch (java.io.IOException e) {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello i have been searching for some php code that is something like element.innerHTML
This should be very easy to do, but somehow after some 15 minutes searching
Possible Duplicate: Subclassing UIView to draw in Quartz Hello i am searching good example
hello I am making web page searching program with windows batch file before searching
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
Hello everyone I'm currently having 2 issues with the code below: Upon return of
Hello I am searching for a graph control that will allow me to make
Hello I'm trying to dynamically generate some inputs for my form, but it's not
Can someone please help. I have been searching and encountered/modified this code I am
I'm building an application with the Dyninst API, and with a simple Hello World

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.