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

  • Home
  • SEARCH
  • 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 6050949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:44:51+00:00 2026-05-23T07:44:51+00:00

This is the code that is used on the Android to encrypt a .zip

  • 0

This is the code that is used on the Android to encrypt a .zip file.

function encryptString($RAWDATA) {
    $key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
    // encrypt string, use rijndael-128 also for 256bit key, this is obvious
    $td = mcrypt_module_open('rijndael-128', '', 'ecb', '');
    $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
    mcrypt_generic_init($td, $key, $iv);
    $encrypted_string = mcrypt_generic($td, strlen($RAWDATA) . '|' .
                    $RAWDATA);
    mcrypt_generic_deinit($td);
    mcrypt_module_close($td);
    // base-64 encode
    return base64_encode($encrypted_string);
}

This is the code for the PHP to decrypt that same .zip file once it is sent to my server.

function decryptString($ENCRYPTEDDATA) {
    $key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";    
        // base-64 decode
        $encrypted_string = base64_decode($ENCRYPTEDDATA);
        // decrypt string
        $td = mcrypt_module_open('rijndael-256', '', 'ecb', '');
        $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
        mcrypt_generic_init($td, $key, $iv);
        $returned_string = mdecrypt_generic($td, $encrypted_string);
        unset($encrypted_string);
        list($length, $original_string) = explode('|', $returned_string, 2);
        unset($returned_string);
        $original_string = substr($original_string, 0, $length);
        mcrypt_generic_deinit($td);
        mcrypt_module_close($td);
        return $original_string; 

It doesn’t seem to work. It will encrypt the .zip file just fine on the Android, but when I call the function in PHP

$zip_file = $path . $strFileName;
                    decryptString($zip_file);

it doesn’t decrypt the .zip file. When I open up the .txt files within the .zip file they are still encrypted.

This is the 2nd encryption code that I have tried since my first attempt didn’t work. Any help would be greatly apprecaited, or if you know of encrypt/decrypt code that works for Android to PHP.

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-05-23T07:44:51+00:00Added an answer on May 23, 2026 at 7:44 am

    This does nothing:

    $zip_file = $path . $strFileName;
    decryptString($zip_file);
    

    You need to send in the actual file contents into decryptString, not the filename. Then you need to catch the return value from the function and write it back to the file. Try something like this:

    $zip_file = $path . $strFileName;
    $decrypted = decryptString(file_get_contents($zip_file));
    file_put_contents($zip_file, $decrypted);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I use this code in my Manifest file: <activity android:name=.MyAct android:label=@string/app_name android:configChanges=orientation|keyboardHidden> //<-SEE
I am trying to rotate an image in OpenCV. I've used this code that
I have this code inside a class that is used by an application and
In this thread some one commented that the following code should only be used
Where is the source code that manages View re-use in Android? I can think
I have this code that performs an ajax call and loads the results into
So I have this code that takes care of command acknowledgment from remote computers,
I have this code that works in a unit test but doesn't work when
Challenge: I have this code that fails to compile. Can you figure out what's
I have this code that I want to make point-free; (\k t -> chr

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.