can we use encryption/decryption for audio file in android
<p>I am quite new to android development please enlighten me on this how to Encrypt and decrypt audio file, that file is very confidential from my application's point of view. Actually i already did encryption and decryption over the audio file which i want to protect, But after doing decryption it shows some Warning Logs for MediaPlayer and media player is not working also. </p>

<p>Logs are mentioned here:</p>

<pre><code>11-14 13:41:42.136: W/System.err(17602): java.io.IOException: Prepare failed.: status=0xFFFFFFFC
11-14 13:41:42.136: W/System.err(17602):    at android.media.MediaPlayer.prepare(Native Method)
11-14 13:41:42.136: W/System.err(17602):    at com.zenagestudios.itaaleemlehra.LessonPlayActivity.startPlayer(LessonPlayActivity.java:293)
11-14 13:41:42.136: W/System.err(17602):    at com.zenagestudios.itaaleemlehra.LessonPlayActivity.onClick(LessonPlayActivity.java:446)
11-14 13:41:42.136: W/System.err(17602):    at android.view.View.performClick(View.java:2461)
11-14 13:41:42.136: W/System.err(17602):    at android.view.View$PerformClick.run(View.java:8890)
11-14 13:41:42.136: W/System.err(17602):    at android.os.Handler.handleCallback(Handler.java:587)
11-14 13:41:42.136: W/System.err(17602):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-14 13:41:42.136: W/System.err(17602):    at android.os.Looper.loop(Looper.java:123)
11-14 13:41:42.136: W/System.err(17602):    at android.app.ActivityThread.main(ActivityThread.java:4632)
11-14 13:41:42.136: W/System.err(17602):    at java.lang.reflect.Method.invokeNative(Native Method)
11-14 13:41:42.136: W/System.err(17602):    at java.lang.reflect.Method.invoke(Method.java:521)
11-14 13:41:42.136: W/System.err(17602):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
11-14 13:41:42.136: W/System.err(17602):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-14 13:41:42.136: W/System.err(17602):    at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>So i just wanted to know that  encryption /decryption have corrupted my audio file?</p>

<p>i have tried the same code of encryption/decryption for some xml file.. and its working fine for it. 
Code i have used for encryption/decryption:</p>

<pre><code> 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)) &gt;= 0){
            out.write(buf, 0, numRead);
        }
        System.out.println("Database Encrypted");
        out.close();
    }
    catch (java.io.IOException e){
        e.printStackTrace();
    }
}
</code></pre>

<p>public void decrypt(InputStream in, OutputStream out){</p>

<pre><code>    try {
        //staticdata. dialog = ProgressDialog.show(mContext, "","Loading. Please wait...", false);
        // 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)) &gt;= 0) {

            out.write(buf, 0, numRead);
        }
        System.out.println("Database Decrypted");

        out.close();
    } 
    catch (java.io.IOException e) {
         e.printStackTrace();
    }

}
</code></pre>
