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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:59:38+00:00 2026-06-06T16:59:38+00:00

I’m trying to create a kind of file generator in Php. Basically, it get

  • 0

I’m trying to create a kind of file generator in Php. Basically, it get a default file, read data, decrypt the data (Encrypted in AES), encrypt the data with the user password and paste all these bytes into a new file with the client name.

This sould be easy but I got some problems. Here is my current code:

// Load the original raw file
$data = file_get_contents('default.bin');
if (!$data) exit();

// Decrypt the raw data with the default key
$data = AESDecrypt($data, 'default_16_b_key');

// Encrypt the raw data with the user key
$data = AESEncrypt(pad($data, 16), $user_key);

$fileName = sprintf('client_%s.bin', $client_name);
file_put_contents($fileName, $data);

Here are the functions I’m using:

function AESEncrypt($data, $key)
{
    return mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_ECB);
}

function AESDecrypt($data, $key)
{
    return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_ECB);
}

function pad($data, $blocksize)
{ 
    $pad = $blocksize - (strlen($data) % $blocksize); 
    return $data . str_repeat(chr($pad), $pad); 
}

The AES functions work well as I can decrypt and encrypt a simple string. The pad function seems to do its job to.

The problem is when I try to execute the generated file (which is a jar file after being renamed), I got this message “Unexpected file end” and nothing into my jar file except a blank file (0 byte).

Could you help me to solve this?

  • 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-06T16:59:39+00:00Added an answer on June 6, 2026 at 4:59 pm

    Finally, I solved it without using the first decryption.
    It’s possible to encrypt the raw data using the following code:

    $data = AESEncrypt(pad($data, 16), $user_key);
    

    You can put that line in an infinite loop (no really infinite btw) and this will still work. Then you can decrypt it in the language of your choice.

    Thanks.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.