NodeTools is a package that provides set of commonly used functionality such as hashing and encoding.
Installation
Using command line
npm i --save nodetools
Functionality
Currently, the below functions are supported. more to come in the future.
- MD5:
hash(str, 'md5');
orhash(str);
- SHA1:
hash(str, 'sha1');
- SHA256:
hash(str, 'sha256');
- SHA512:
hash(str, 'sha512');
- Validate Email:
validateEmail(str);
- Check if is numeric:
isNumeric(nunmber);
- Base64 encode/decode:
base64Encode(str);
andbase64Decode(str);
- Check if variable is set:
isSet(var);
- URL encode/decode:
urlEncode(str);
andurlDecode(str);
- Detect mime-type:
detectType(str);
Example
var ntools = ; console; // MD5 by defaultconsole; // SHA1console; // Base64 encodeconsole; // application/json
If you have ES6 support:
; console; // MD5 by defaultconsole; // SHA1console; // Base64 encodeconsole; // application/json