Code Monkey home page Code Monkey logo

hashcasher's Introduction

hashcasher

Protect online forms from spam by making them perform Proof of Work (PoW).

Use (Browser)

Place hashcasher.js, sha3.js, and worker.js in the highest-level directory that you wish to be protected by hashash. This is important, because the worker process (which handles the heavy load of crypto, away from the UI thread) can only be used when it is at or above your current depth in the tree.

Add to the page of the form which you'd like to protect:

<script src="/hashcasher.js"></script>

Change your <form> element to have the require property set to hashcash:

<form method="POST" action="/some-endpoint" require="hashcash">
  ...
</form>

The form's submit handler will be used to consume the form's data (its <input> values), pass them to worker.js to compute the proof of work, then submit the form with an attached X-Hashcash header.

Use (Server)

Hashcasher comes with a Connect-style middleware, for use in applications built with things like Express. Using it is simple:

// specify the difficulty as "2"
var hashcash = require('hashcasher')(2);

app.post('/some-endpoint', hashcash, ...);

Testing

npm install -g http-server and http-server ., then visit localhost:8080/test.html.

hashcasher's People

Contributors

martindale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

hashcasher's Issues

Distribution?

With the requisite of a WebWorker for doing time-intensive processing (proof of work in our case), it seems we need to distribute both the hashcasher.js and worker.js files, and possibly also sha3.js. Normally, I'd expect to "bundle" a single file for distribution, but our case seems different.

How can we make installing Hashcasher as simple as possible?

Handler API

It'd be nice to handle API errors and display them to the user in a semi-standard fashion. Began some work in #3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.