0.0.7 • Published 6 years ago

node-autho v0.0.7

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

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
0.0.7

6 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago