npm.io
1.0.2 • Published 11 years ago

url-hash

Licence
MIT
Version
1.0.2
Deps
1
Vulns
0
Weekly
0
Stars
2

url-hash

Node library to add hash parameter for tamper-free urls

Basic Usage

Add hash to url


// require library
var urlHash = require('url-hash');

var url = 'http://www.example.com/page?id=4';

// add hash to url
var newUrl = urlHash.create(url);
Verify Url

// require library
var urlHash = require('url-hash');

// check integrity of url
var result = urlHash.check(url/to/verify);

/*

  result will either:
  1. equal true if the url is unchanged
  2. equal false if the url has been changed

*/

Configuration options

This library currently offers the following configuration options:

  • salt
  • expire
  • hash key name

urlHash.config({
                salt:    'someUniqueCustomSalt', // use custom salt (recommended)
                expire:  60000,                  // url expires after 1 minute
                hashKey: 'myCustomHashKeyName'   // use custom name for hash parameter
              });

Keywords