diff --git a/README.md b/README.md new file mode 100644 index 0000000..86fdab5 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +Organic Hash +============ + +Converts strings to awesome scifi objects!! + +Organic Hash hashes strings (user ID, hashes) to a human-readable, scifi-themed +representation. + +## Demo + +http://truly-civilized-pancakes.herokuapp.com + +## Install + +```bash +$ npm install organic_hash --save +``` + +## Usage + +Basic usage + +```javascript +var organicHash = require('organic_hash')(); +organicHash.hash('ID_A3AHG7FKPIV07') +// "clearly-mongoloid-pressure" + +organicHash.hash('asldkjasldkjasdlkajsd') +// 'technically-common-device' + +organicHash.hash('nhahn') +// 'dangerously-successful-gun' +``` + +Different length + +```javascript +var organicHash = require('organic_hash')(4); +organicHash.hash('Zero') +// 'slowly-regular-personally-hibernation' +``` + +Random hashes + +```javascript +var organicHash = require('organic_hash')(); +organicHash.rand(); +// 'purposefully-weak-neurotoxin' +``` + +## Authors + +Nathan Hahn ported the library to Javascript +Joseph Chee Chang and Zero Cho + +## License + +Apache License, Version 2.0 + +## URL + +https://github.com/nhahn/organic_hash + + diff --git a/index.js b/index.js index 9d3b4cb..64d7583 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,10 @@ var SHA256 = require("crypto-js/sha256"); var fs = require("fs"); +var path = require("path"); -var NOUN = fs.readFileSync('data/noun.dat').toString().split('\n'); -var ADJ = fs.readFileSync('data/adj.dat').toString().split('\n'); -var ADV = fs.readFileSync('data/adv.dat').toString().split('\n'); +var NOUN = fs.readFileSync(path.join(__dirname, 'data', 'noun.dat')).toString().split('\n'); +var ADJ = fs.readFileSync(path.join(__dirname, 'data', 'adj.dat')).toString().split('\n'); +var ADV = fs.readFileSync(path.join(__dirname, 'data', 'adv.dat')).toString().split('\n'); // Adds two arrays for the given base (10 or 16), returning the result. // This turns out to be the only "primitive" operation we need. diff --git a/package.json b/package.json index ab32740..d066347 100644 --- a/package.json +++ b/package.json @@ -1,18 +1,24 @@ { - "name": "orgnic_hash", - "version": "1.0.0", - "description": "A javascript version of josephcc organic hash", + "name": "organic_hash", + "title": "organic_hash", + "version": "1.0.1", + "description": "Converts strings to awesome scifi objects!! A port of the Josephcc ruby gem of the same name", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, + "repository": { + "type": "git", + "url": "https://github.com/nhahn/organic_hash" + }, + "homepage": "https://github.com/nhahn/organic_hash", "keywords": [ "hash", - "nlp" + "crypto" ], "author": "Nathan Hahn", - "license": "MIT", + "license": "Apache-2.0", "dependencies": { - "crypto-js": "^3.1.5", + "crypto-js": "^3.1.5" } }