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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:35:30+00:00 2026-05-31T15:35:30+00:00

I have a script that read a mp3 file and encrypt it, I want

  • 0

I have a script that read a mp3 file and encrypt it, I want to be able to decrypt this file and convert it to base64 so it can play in html5.

Key 1 will be stored on the page and static, key2 will be unique for each file, for testing I used:

$key1 = md5(time());
$key2 = md5($key1.time());

Here is my encode php code :

//Get file content
$file = file_get_contents('test.mp3');
//Encrypt file
$Encrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key1, $file, MCRYPT_MODE_CBC, $key2);
$Encrypt = trim(base64_encode($Encrypt));
//Create new file
$fileE = "test.mp3e"; $fileE = fopen($file64, 'w') or die("can't open file");
//Put crypted content
fwrite($fileE, $Encrypt);
//Close file
fclose($fileE);

Here is the code that doesnt work (decoded file is same size, but no mimetype):

//Get file content
$fileE = file_get_contents('test.mp3e');
//Decode
$fileDecoded = base64_decode($fileE);
//Decrypt file
$Decrypt = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key1, $fileDecoded, MCRYPT_MODE_CBC, $key2);
$Decrypt = trim($Decrypt);
//Create new file
$file = "test.mp3"; $file = fopen($file, 'w') or die("can't open file");
//Put crypted content
fwrite($file, $Decrypt);
//Close file
fclose($file);
  • 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-31T15:35:31+00:00Added an answer on May 31, 2026 at 3:35 pm

    I guess your pointing on the wrong file take a look on this code:

    $fileE = "test.mp3e"; $fileE = fopen($file64, 'w') or die("can't open file");
    

    Then check the file your trying to decrypt:

    $fileE = file_get_contents('test.mp3e');
    

    I think you have a mistake on the filename. Not sure wasn’t able to see what the value of variable $file64 is. Though you have assigned the filename value on $fileE value as “test.mp3e” it would still get what you defined on $file64 though. 🙂

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

Sidebar

Related Questions

I have a Perl script that uses WWW::Mechanize to read from a file and
I have a powershell script that needs to read from a config file with
I have this script that needs to replace a file extension and it is
I have a script in python that needs to read iso-8859-1 files and also
I have a script that takes a table name and generates a control file
If I have a script that writes 1000 lines to file and then continues
I have a script that checks if a file exists or not using the
I have a script that generates xml of products on users webstores. Now, this
I have a script that pulls a file's contents and then echos it out
I have a script that creates file system in a file on a linux

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.