Skip to content

Instantly share code, notes, and snippets.

@kitek
Created January 8, 2012 17:50
Show Gist options
  • Save kitek/1579117 to your computer and use it in GitHub Desktop.
Save kitek/1579117 to your computer and use it in GitHub Desktop.
NodeJS create md5 hash from string
var data = "do shash'owania";
var crypto = require('crypto');
crypto.createHash('md5').update(data).digest("hex");
@arash-bizcover
Copy link

@leafyshark calm down brother, there are absolutely many use-cases for hashing, these are some obvious, to validate the integrity of some data:

  1. You have some input on a function that you want to be able to identify if the new revocation of the func has the same input or not. So instead of storing the state of all inputs (possibly large objects) somewhere in a DB, you can just store a hash of it (as a Tag) and just check that.
  2. You want to make an ID (identity) based on many different fields to be able to track, lets say in the LOGS; useful on systems not having any ID set, OR just need to make a dynamic ID for example based on IP address and Email (differentiating a user based on their location)
  3. You have a large file that you want to check if it has been changed or it is the same so you just save and check the hash of it and check the hash later, rather than saying check 3GB of data byte by byte (i.e file checksum)

@the-night-wing
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment