Journal

ebook download security question

  • Posted on: September 08, 2005
  • In: Personal
  • Comments closed

A friend of mine is planning on self-publishing a book, via a website as a downloadable pdf, and then through something like Lulu for people who want a nicely bound offering.

So, the question is Paypal. I've got as far as going through the documentation, seeing how you can set up a pay now button etc. Which then directs back to the website for downloading the file.

My question is this. How secure is that? Or rather, how secure is the page on which you can download it? What measures can I put in place to maximise security? I'm only asking because googling this just gives a list of commercial companies hell-bent on trying to sell you something.

Anyone able to shed some light on this?

Comments

Here’s an idea…

You could set up a small database that would contain their email address and a hashed (MD5 or SHA-1) string made up of some key plus their email address.

When they purchase the book, send them a link with the hashed string and their email address in the URL parameters. The program would look up their record from the parameters supplied, re-hash the email address, and then provide the file download if everything checks out.

For extra security, you could also get their IP address or set a cookie, and only serve up the eBook if those credentials match too.

Hope this helps…

Ryan Heneise's Gravatar

Ryan Heneise
Thu 8th Sep 2005
at 5:10 pm

There is a similar technique posted on Signal vs. Noise called “URL or Username and Password?”, posted 30 Aug 2005. (Your comment form won’t let me post the link.)

Ryan Heneise's Gravatar

Ryan Heneise
Thu 8th Sep 2005
at 5:21 pm

Hey Mark - I recently made a similar post in the 9rules Site Suggestions forum. The guys had some good advice.

I’m in the same boat and stepping through the process. Basically, I am trying to direct users to a secure pdf download. Paypal returns to our site, and a page process the download. I started with the following code:

$dir="yourdir/";

$file=$dir."filename.psd";
header("Content-type: application/force-download");
header("Content-Transfer-Encoding: Binary");
header("Content-length: “.filesize($file));
header("Content-disposition: attachment; filename=\"haha.psd\"");
readfile("$file");

This works pretty well because you can hide the path and filename from the user, so the only way to access the file is some good guessing. It is not 100% safe though, so I am in the process of trying to implement what they suggested - keeping the file outside of the web file structure.

Anyways, once my setup is finished I will let you know. You are more than welcome to use my code. The only difference with mine is that we have a database with username/passwords so it is easy to verify. In yours, some type of hash code will need to be stored just as Ryan suggested.

Ryan Campbell's Gravatar

Ryan Campbell
Thu 8th Sep 2005
at 5:56 pm

Just thought I’d put a little disclaimer on my comment above… I haven’t tried it yet, so I don’t know if it would actually work. It’s probably one of a zillion ways to do this.

I’d be really interested to hear what you end up doing.

Ryan Heneise's Gravatar

Ryan Heneise
Thu 8th Sep 2005
at 6:23 pm

Ryan Heneise - Thanks Ryan, well I’m not the most adept programmer in the world so actually implimenting this theory of yours might prove tricky! ;). Thanks for the tips though.

Ryan Cambell - Hey Ryan. I’d forgotton you were going through something similar actually. This sounds exactly what I’m after. Let me know when you’re done and I’ll try and get to work on it. Not so sure how to implement al this talk of hashes and things…

Mark Boulton's Gravatar

Mark Boulton
Thu 8th Sep 2005
at 8:03 pm

Sounds good - we should be doing testing shortly, and then I’ll have some more concrete stuff to give you.

Ryan Campbell's Gravatar

Ryan Campbell
Thu 8th Sep 2005
at 11:49 pm

I use LinkLok for Payapl IPN to handle the secure download of the content I sell on my site. The developer is very responsive and I’m very pleased with the product.

Rob Babcock's Gravatar

Rob Babcock
Fri 9th Sep 2005
at 12:06 am

You could ask Dave how they do it. I bought a PDF book from them and they emailed me a special unique url to download it after it was prepared. Prepared seemed to be customizing the PDF with a “ Prepared exclusively for Michael D Zornek” at the footer of each page. Other than that though no DRM (which is important for me).

Adam also sells PDFs online and might be able to give some advice.

Good luck!

Mike Zornek's Gravatar

Mike Zornek
Fri 9th Sep 2005
at 2:23 am

Ryan - Thanks for that. Lookign forward to seeing it.

Rob - That does look like an interesting product and quite feature rich.

I noticed on your site, you use Cafepress for your printed material. How do you find the quality of the books they produce? Also, do they offer full colour book printing for distribution in the UK? I couldn’t find any information about that anywhere.

Mark Boulton's Gravatar

Mark Boulton
Fri 9th Sep 2005
at 10:01 am

Just found this scriptwhich looks like it could be helpful in facilitating pdf sales over paypal. Requires a bit of setup but cheaper than buying a pre-made solution.

Also, these guys offer a service similar: http://payloadz.com/

Craig's Gravatar

Craig
Fri 9th Sep 2005
at 10:39 am

(Here’s the <a href="http://www.hotscripts.com/Detailed/46734.html">Link</a> for the script.)

Craig's Gravatar

Craig
Fri 9th Sep 2005
at 11:29 am

Mark, I did a similar thing with an ASP solution a year or so ago.  Found some code that would read through a binary file and “feed” it to the web browser (ASP called it a file stream).  So the user thought they were downloading thefile.asp, but it returned a content type of application/pdf and then the binary for the PDF file they requested through the query string.  It worked well.  And yes, you will want to store the PDF outside the web folder structure.

Nathan Rutman's Gravatar

Nathan Rutman
Mon 12th Sep 2005
at 12:49 pm

Commenting is not available in this section entry.

Next entry: Feeds now fixed

Previous entry: Refreshing Minty goodness


A picture of Mark BoultonI'm a graphic designer from near Cardiff in the UK. I've been a designer for over ten years now and primarily work on the web. I'm still partial to a bit of print every now and then though. I used to work for Agency.com in London as an Art Director before working as a Senior Designer for the BBC in sunny Cardiff. This was all before I took leave of my senses and formed my own design consultancy, Mark Boulton Design Ltd.

I've got a thing about grids and typography and occasionally ramble on about them to anyone who will listen.

If you're after simple, clean and effective web design; let me know.