node-autho

0.0.7 • Public • Published

node-autho

Simply utility for handling password comparison, generating auth tokens, etc.

Usage

npm install node-autho

Require in the library:

var autho = require("node-autho");

Methods

autho.encrypt(str,key)

The encrypt method can be passed a manual key, or it can use a key on the server, outside of the web path.

To use a manual input key:

var gen = autho.encrypt("the quick brown fox", "some-key");

To use a server key:

autho.certPath = "/var/data/cert.txt";
autho.encrypt("the quick brown fox").then(function(res){
  // Encrypted string
});

autho.decrypt(hash,key)

In the same manner, decryption can be done with a manual or server key.

var dec = autho.decrypt(gen, "some-key");

Or

autho.decrypt("1c9722fe55943f7bd5c4aac76d5d102a").then(function(res){
  // Decrypted string
});

autho.encryptPassword(str)

One-way encryption for password comparison can be accomplished like so:

autho.encryptPassword("the quick brown fox").then(function(hash){
  // Save to a database
});

autho.comparePassword(str,hash)

To compare the encrypted string:

autho.comparePassword("the quick brown fox", hash).then(function(){
  // Comparsion passed
},
function(){
  // Comparison failed
});

Test

If you don't already have mocha installed:

npm install mocha -g

Then:

npm test

Readme

Keywords

none

Package Sidebar

Install

npm i node-autho

Weekly Downloads

0

Version

0.0.7

License

MIT

Unpacked Size

6.22 kB

Total Files

5

Last publish

Collaborators

  • erikuix