I am Hack Sparrow
Captain of the Internets.

A Port Scanner in Node.js

In this tutorial, I will show you how to write a port scanner in Node.js! Hope this tutorial helps remove the misconception that Node is only for serverside programming and creating websites. First off, what is a port scanner? A port scanner is a software that automates the process of checking if a port is open on a machine. There are various levels of sophistication when it comes to scanning ports, and there are numerous tools that are hailed as industry standard, but in this tutorial we wil ...

Express.js HTTPS Server Client Example

In this tutorial I will show you how to set up an HTTPS ExpressJS server and connect to it using a TLS client. I will assume you already know how to set up a basic Express.js app, if not read this tutorial. Create an Express app, and use the following code as the server: [code] var fs = require('fs'); var express = require('express'); var https = require('https'); var key = fs.readFileSync('./k ...

Base64 Encoding / Decoding in Node.js

So how do you encode a string to base64 is Node.js? Is there something easy like base64_encode() of PHP's? Node.js 'being' JavaScript, has a more logical approach to encoding strings, instead of having thousands of inconsistently defined global functions. Here is how you encode normal text to base64 in Node.js: [code] var b = new Buffer('JavaScript'); var s = b.toString('base64'); // SmF2YVNjcmlwdA== [/code] And here is how you decode base64 encoded strings: [code ...

How to Generate md5, sha1, sha512, sha256 Checksum Hashes in Node.js

Checksums in Node.js are generated using the crypto library's createHash() method. The usage format is this: [code] crypto.createHash(algo) [/code] Where algo is the algorithm of your choice - md5, sha1, sha512, sha256 etc. The algorithms supported are entirely dependent on the OpenSSL version on your machine. Here are some examples of generating hashes for string inputs: [code] var crypto = require('crypto'); var md5 = crypto.createHash(' ...

Node.js compilation error on Ubuntu – Install using apt-get

This post this written for people who will encounter this mysterious Node.js compilation error. [code] *** glibc detected *** /usr/lib/gcc/i686-linux-gnu/4.6.1/cc1plus: malloc(): smallbin double linked list corrupted: 0x0a4a0eb8 *** ... /home/$USER/Downloads/node-v0.6.15/deps/v8/src/ia32/lithium-ia32.cc: In member function 'int v8::internal::HTemplateInstruction::OperandCount() [with int V = 2]': /home/$USER/Downloads/node-v0.6.15/deps/v8/src/ia32/lithium-ia32.cc:2265:3: internal compi ...