apinstein/expiring-hash

A utililty to easily create crypographically signed URLs for temporary ad-hoc URL access.

Installs: 2 044

Dependents: 1

Stars: 10

Watchers: 1

Forks: 2

Language: PHP

v0.0.2 2013-02-12 16:48 UTC

README

ExpiringHash

Small helper class to create a URL parameter containing a tamper-proof expiration date.

This allows you to implement expiring URLs in the same way that Amazon S3 supports.

// create
$eh = new ExpiringHash('my secret');
$hash = $eh->generate("15 minutes");
$url = "http://foo.com/mydownload?hash={$hash}";

// verify
$eh = new ExpiringHash('my secret');
$okToDownload = $eh->validate($_GET['hash']);