mkboice / Node-Password-Hash

Main submission for interview project.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#Node Password Hash

##Setup

  1. git clone
  2. npm install

##Run

  1. npm start - to start server
  2. npm test - to run tests (Server is started within the tests. Don't need to run npm start.)

##Requirements

  • The project should be written in NodeJS using only the standard library.
  • When launched it should monitor a given port and wait for http connections.
  • When a connection is made it should not respond immediately, but rather hold the socket open for 5 seconds and then respond.
  • The connection will be a POST request containing a value that the client wishes to be hashed.
  • The hashing algorithm should be SHA512.
  • The result should be returned base64 encoded.
  • The software should be able to process multiple connections simultaneously.
  • If, instead of a password request the software receives a "graceful shutdown" request, it should allow any remaining password requests to complete, reject any new requests, and shutdown.
  • No additional password requests should be allowed when shutdown is pending.

##Example For instance, given the request (generated by curl): curl --data "password=angryMonkey" http://localhost:8080

Your program should return ZEHhWB65gUlzdVwtDQArEyx+KVLzp/aTaRaPlBzYRIFj6vjFdqEb0Q5B8zVKCZ0vKbZPZklJz0Fd7su2A+gf7Q==

##Asumptions

  • Status code 400 'Bad Form Parameter' is returned if the form key is not "password"
  • Status code 404 'Not Found' is returned on any request other than a POST

##Notes

  • index.js only uses NodeJS core modules
  • test.js uses other npm modules to aid in testing
  • Tests have console output to aid in visualizing what is happening. Normally I would log it to a file and not console.

About

Main submission for interview project.


Languages

Language:JavaScript 100.0%