1.0.1 • Published 4 years ago

@basekits/kit-node-hashing v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@basekits/kit-node-hashing

Hash functions kit for basekits and node runtime.

Install

npm i @basekits/kit-node-hashing

Usage

const kit = require('@basekits/core')
const hashing = require('@basekits/kit-node-hashing')
kit.addKit(hashing)

Available Items

The following methods will be available after adding this kit:

.hash(data, algorithm = 'md5')

Returns hash of some data. data can be anything which node's crypto library accepts.

kit.hash('asdfghjklşi') // returns 'e1f301ea36789e07a445c6341bd88cbd'

.hashFile(filepath, algorithm = 'md5')

Returns hash of a file.

kit.hashFile('/path/to/somefile.txt') // returns 'e1f301ea36789e07a445c6341bd88cbd'

.hashcode(str)

Java's hashcode implementation in javascript. (Credits goes to: stackoverflow.com) Returns positive or negative number.

kit.hashcode('hello') // returns 99162322
kit.hashcode('lorem ipsum') // returns -2126368101