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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:41:43+00:00 2026-05-27T16:41:43+00:00

Abstract: reading images from file with toggled bits to make unusable for preview tools

  • 0

Abstract:

  • reading images from file
  • with toggled bits to make unusable for preview tools
  • cant use encryption, to much power needed
  • can I either optimize the code below, or is there a better approach

Longer description:

I am trying to improve my code, maybe you got some ideas or improvements for the following situation. Please be aware that I neither try to beat the CIA, nor care much if somebody “brakes” the encryption.

The background is simple: My app loads a bunch of images from a server into a folder on the SD card. I do NOT want the images to be simple JPG files, because in this case the media indexer would list them in the library, and a user could simply copy the whole folder to his harddrive.

The obvious way to go is encryption. But a full blown AES or other encryption does not make sense, for two reasons: I would have to store the passkey in the app, so anyone could get the key with some effort anyway. And the price for decrypting images on the fly is way too high (we are talking about e.g. a gallery with 30 200kB pictures).

So I decided to toggle some bits in the image. This makes the format unreadable for image tools (or previews), but is pretty easy undone when reading the images. For “encrypting” I use some C# tool, the “decrypt” lines are the following ones:

public class CustomInputStream extends InputStream {
    private String _fileName;
    private BufferedInputStream _stream;


    public CustomInputStream(String fileName) {
        _fileName = fileName;
    }

    public void Open() throws IOException {
        int len = (int) new File(_fileName).length();
        _stream = new BufferedInputStream(new FileInputStream(_fileName), len);
    }


    @Override
    public int read() throws IOException {
        int value = _stream.read() ^ (1 << 7);
        return value;
    }


    @Override
    public void close() throws IOException {
        _stream.close();

    }

}

I tried overwriting the other methods (read with more then one byte) too, but this kills the BitmapFactory – not sure why, maybe I did something wrong. Here is the code for the image bitmap creation:

Bitmap bitmap = null;
try {
    InputStream i = CryptoProvider.GetInstance().GetDecoderStream(path);
    bitmap = BitmapFactory.decodeStream(i);
    i.close();
} catch (Exception e1) {
    _logger.Error("Cant load image " + path + " ERROR " + e1);
}
if (bitmap == null) {
    _logger.Error("Image is NULL for path " + path);
}
return bitmap;

Do you have any feedback on the chosen approach? Any way to optimize it, or a completely different approach for Android devices?

  • 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-27T16:41:44+00:00Added an answer on May 27, 2026 at 4:41 pm

    You could try XORing the bytestream with the output of a fast PRNG. Just use a different seed for each file and you’re done.

    note: As already noted in the question, such methods are trivial to bypass.

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

Sidebar

Related Questions

I'm reading about AST (abstract syntax trees) but all the samples I see use
I'm reading about permutations and I'm interested in ranking/unranking methods. From the abstract of
I am currently reading a CSV file. I have to extract the dates from
Many frameworks seek to abstract away from HTML (custom tags, JSFs component system) in
I have been reading documentation describing class inheritance, abstract base classes and even python
I have the following function for reading a big-endian quadword (in a abstract base
I was reading A Tour of Scala: Abstract Types . When is it better
When reading the tutorial of Properties Tutorial from MSDN. I'm consused about the example.
I'm trying to make a button class (abstract) so I can set what function
I've been reading this http://msdn.microsoft.com/en-us/magazine/cc163681.aspx and found the part about defining abstract base classes

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.