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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:47:45+00:00 2026-05-24T01:47:45+00:00

So I have a little problem.I can’t find how to save a bitmap file

  • 0

So I have a little problem.I can’t find how to save a bitmap file after decryptation in sdcard or somewhere else where I can view the image (no matter where).The code I am using now is :

public class SimpleCryptoActivity extends Activity {
    private static final int IO_BUFFER_SIZE = 4 * 1024;
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

                try {
                    AssetManager am = this.getAssets();
                    InputStream is = am.open("2000_1.jpg_encrypted"); // get the encrypted image from assets folder

                    ByteArrayOutputStream baos = new ByteArrayOutputStream();  
                    byte[] b = new byte[IO_BUFFER_SIZE];  
                    int read;  
                    while ((read = is.read(b)) != -1) {  //convert inputstream to bytearrayoutputstream
                        baos.write(b, 0, read);
                    }                           
                long start = System.currentTimeMillis()/1000L; // start

                    byte[] keyStart = "MARTIN_123_MARTIN_123".getBytes();  // specific key value 
                    KeyGenerator kgen = KeyGenerator.getInstance("AES");    //aes
                    SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
                    sr.setSeed(keyStart);
                    kgen.init(128, sr); 
                    SecretKey skey = kgen.generateKey();
                    byte[] key = skey.getEncoded();    

                    byte[] decryptedData = decrypt(key,b);  //decryption
                long end = System.currentTimeMillis()/1000L;    // end
                Log.i("TEST","Time start "+ String.valueOf(start)); //showing the strat in ms
                Log.i("TEST","Time end "+ String.valueOf(end));     //showing the end in ms
                    Bitmap bitmap = BitmapFactory.decodeByteArray(b , 0, b .length);    //decoding bytearrayoutputstream to bitmap



                    is.close(); // close the inputstream
                    baos.close(); // close the bytearrayoutputstream
                }
                catch(Exception e){
                    e.fillInStackTrace();
                }
            } 

            //decrypt
            private byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {
                SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
                Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
                byte[] decrypted = cipher.doFinal(encrypted);

            return decrypted;
            }
}

Another question too.I’m curious why I can’t see the

Log.i("TEST","Time start "+ String.valueOf(start)); //showing the strat in ms
                Log.i("TEST","Time end "+ String.valueOf(end));     //showing the end in ms

in the LogCat.Am I doing something wrong or…?Thanks for help!

  • 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-24T01:47:46+00:00Added an answer on May 24, 2026 at 1:47 am

    If it is not important if you store it on the SD or any storage at all. You can add ImageView in your layout and do

    ImageView mydecrptimg = (ImageView)findViewById(R.id.imageview);
    
    mydecrptimg.setImageBitmap(yourbitmap);
    

    or store it to MediaStore. Read more here about this provider

    http://developer.android.com/reference/android/provider/MediaStore.Images.Media.html

    Edit: put this class inside your current class, then instantiate for your ImageView

     private class DrawMyBitmap extends ImageView{
    
            private Bitmap bmp = null;
            public DrawMyBitmap(Context context, Bitmap mybmp) {
                super(context);
                this.bmp=mybmp;
            }
    
            @Override
            protected void onDraw(Canvas canvas) {
    
                 Paint paint = new Paint();
    
                 paint.setFilterBitmap(true);
                 paint.setAntiAlias(true);
    
                 Rect bmprect = new Rect(0 ,0 , bmp.getHeight(), bmp.getWidth() );
                 canvas.drawBitmap(bmp, null, bmprect, paint);
                super.onDraw(canvas);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little problem with a Listview. I can load it with listview
I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
I have a little problem that I can't figure out how to solve. I
I have little problem with specifying my variable. I have a file with normal
I have a little problem that perhaps you can help me with. I try
I have a little problem and I'm hopping that you can help me solve
I have a little problem and I don't know how can I fix it
I have a little problem - i would can get with this query topics
Evening :) I have a little problem... As you can see in my code
Hey guys, I have a little problem with a simple ajax request. I can't

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.