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

The Archive Base Latest Questions

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

I have this PHP function (using PHP 5.3) that I use to decrypt files,

  • 0

I have this PHP function (using PHP 5.3) that I use to decrypt files, it used to work just fine, but now that I moved to Amazon EC2 (based on Amazon Linux Image 2012.3), it seems that mcrypt install is either corrupted or not available at all.

Initial tests suggests that file decryption does work on smaller files, but not on 20MB+ files (which is not a particularly large size).

I tracked the problem down to this line, which is causing an Error 500 (I’m not getting mcrypt_module_open is undefined, just 500 server error)

$td = mcrypt_module_open ('rijndael-128', '', 'cbc', '');

What’s strange, I checked /etc/php.ini, I can’t see mcrypt at all (assuming I’m looking at the correct php.ini/path of course!)

The PHP code/function is:

function decrypt_file ($inputfile, $outputfile)
{
    $key        = FILE_KEY;  // <-- assign private key
    $buffersize = 16384;

    // Open $inputfile for reading binary
    $input      = fopen ($inputfile, 'rb');

    // Error opening $inputfile, return false
    if (!$input)
        return false;

    // Open $outputfile for writing binary
    $output     = fopen ($outputfile, 'wb');

    // Error opening $outputfile, return false
    if (!$output)
        return false;

    // Open the cipher module
    $td = mcrypt_module_open ('rijndael-128', '', 'cbc', '');

    // Read the IV from $inputfile
    $iv = fread ($input, 16);

    // Compute the SHA512 of the IV (salt) and Key and use 32 bytes (256 bit) of the result as the encryption key
    $keyhash = substr (hash ('sha512', $iv . $key, true), 0, 32);

    // Intialize encryption
    mcrypt_generic_init ($td, $keyhash, $iv);

    while (!feof ($input))
    {
        $buffer = fread ($input, $buffersize);

        // Encrypt the data
        $buffer = mdecrypt_generic ($td, $buffer);

        // Remove padding for last block
        if (feof ($input))
        {
            $padsize = ord ($buffer[strlen ($buffer) - 1]);
            $buffer  = substr ($buffer, 0, strlen ($buffer) - $padsize);
        }

        // Write the encrypted data to $output
        fwrite ($output, $buffer, strlen ($buffer));
    }

    fclose ($input);
    fclose ($output);

    // Deinitialize encryption module
    mcrypt_generic_deinit ($td);

    // Close encryption module
    mcrypt_module_close ($td);

    return true;
}

Anyone knows how to fix that? I’m using PHP 5.3 with CodeIgniter 2.1 (thought this is most likely not related to CodeIgniter)

  • 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-04T04:00:12+00:00Added an answer on June 4, 2026 at 4:00 am

    It looks like you don’t have mcrypt installed. Try running:

    sudo yum install php-mcrypt
    

    …from the command line on your instance.

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

Sidebar

Related Questions

this is function.php of a wordpress theme that NOD32 says this code have a
I have this PHP include file that has all the variables I'll be using.
I am in a pickle right now... I have this function that gets 2
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left
I have this in my class When the second function is called php errors
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),
I have this code in userpage.php: <script langauge=JavaScript><!-- function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); } //--></script>
I have an issue about writing HTML file with PHP. I have this function

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.