Skip to content

Commit

Permalink
add usage in README
Browse files Browse the repository at this point in the history
  • Loading branch information
bibig committed Apr 19, 2013
1 parent cd4e165 commit 0f20a4d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules/
32 changes: 29 additions & 3 deletions README.md
@@ -1,4 +1,30 @@
node-shorthash
==============
# shorthash

get an unique short hash of a string
A mini Node.js module to generate short, alpha-number, undecryptable and unique hash id from a long string (utf8 format).
Use shorthash when you want to encrypt a string like a movie name or a people name to a short, unique and url friendly id.
so with shorthash, you can build an id-string map.
instead of quering the id from db each time, you just calculate the id out on the fly.
it's quite convenient in many conditions if you want to build a site like (书本画)[http://shubenhua.com], a books search engine in China.


## Usage

#### less's more, no options, just unique the string.

```javascript

var sh = require("shorthash");

console.log(sh.unique('foobar@example.com'));
// you will get: Z1bL2tE

console.log(sh.unique('my name is really big big and big...'));
// you will get: Z1TirWS

console.log(sh.unique('万里长城永不倒。。。'));
// you will get: 2r6EFF

console.log(sh.unique('和平'));
// you will get: 33NM

```

0 comments on commit 0f20a4d

Please sign in to comment.