This is a quick how to in creating a simple MD5 hash in your Node.js application. I am not recommending this for security or to be the best practice for protecting your data, so here is a little background. Marvel comics just released an API at developer.marvel.com and one of the requirements is to pass them an MD5 hash of a timestamp, public key, and private key. Being the geek I am I said okay and proceeded to do my thing.
This is so simple it might make you laugh. To create an MD5 hash in Node.js… drumroll….
var data = "what ever secret I could think of";
var crypto = require('crypto');
var hashedValue = crypto.createHash('md5').update(data).digest("hex");
Like many developers I use git to handle my version control, and with that I sometimes forget a little file called .gitignore. When I forget that file I end up versioning things that don’t need to be, or cluttering a remote repository with junk no one else wants like ide specific files, a node_modules directory, or any other group of documents and configuration files that would be unique to me.
Here is a basic .gitignore template file I start with for my projects. You can also find a nice list of other configurations at Sujee Maniyam’s blog.
But here is mine that is set up for Node development using IntelliJ and or Sublime.
Just create a file named .gitignore and place it in the root directory that you are about to run git init. Tada, no more messy stuff when you add, commit, and push.
## .gitignore file for project
## generic file ignore
## Project file and directory ignore
## IDE Specific ignores
## Node ignore