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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:06:11+00:00 2026-05-30T04:06:11+00:00

Code first, then an explanation: <?php header(Content-Type: application/octet-stream); header(Content-Disposition: attachment; filename=\.$_POST[‘filename’].\); $key = md5(rand());

  • 0

Code first, then an explanation:

<?php
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$_POST['filename']."\"");
$key = md5(rand());
echo $key;
$key = str_repeat($key,ceil(strlen($_POST['data'])/32));
echo $_POST['data'] ^ $key;
?>

What this does is allow me to POST data through a form (dynamically generated) and have the posted data be downloaded as a file.

I’m using a very basic XOR encryption that puts the (fixed-length, 32-byte) key at that start of the file. The intention is not to secure the data, but rather to obfuscate it.

Having such a file means that potentially anyone could POST whatever data they wanted to it and it would be offered as a download to the user’s computer, but I believe a combination of the user having to accept the download, and the data being passed through XOR with a one-time key, is enough to prevent malicious use.

Is there any reason why I should not use such a file? Are there better alternatives to what I’m doing? Is application/octet-stream the appropriate MIME-type?

  • 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-30T04:06:13+00:00Added an answer on May 30, 2026 at 4:06 am

    It is completely safe from user’s perspective – because it makes no sense for user to harm itself and POST cannot be passed by potentially malicious url or redirect. And even if it could – there is just a script that returns a file to download. This cannot harm anyone by definition.

    But you should keep in mind that after you sent it to user – you can never trust the data in case that you accept the data to deobfuscate and use in some way.

    Is application/octet-stream the appropriate MIME-type

    As long as you return binary data – yes, it is appropriate

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

Sidebar

Related Questions

I was trying to deploy my source code onto Github. Then, I first added
Code first: '''this is main structure of my program''' from twisted.web import http from
I often refactor code first by creating an inner class inside the class I'm
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
I'm using the STL map data structure, and at the moment my code first
i am stuck at scope resolution in python. let me explain a code first:
here's the main code at first I thought is was the message box but
Which one below is correct? First code has no quotes in the $_GET array
I got the problem that the if-statement doesn't work. After the first code line
First my code $.getJSON(./posts/vote/ + postId + /1, null, function(result) { if (result.result ==

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.