Pathologic was missing because of a .git folder inside.
[yaffs-website] / node_modules / hasha / readme.md
1 <h1 align="center">
2         <br>
3         <br>
4         <br>
5         <img width="380" src="https://rawgit.com/sindresorhus/hasha/master/media/logo.svg" alt="hasha">
6         <br>
7         <br>
8         <br>
9         <br>
10         <br>
11 </h1>
12
13 > Hashing made simple. Get the hash of a buffer/string/stream/file.
14
15 [![Build Status](https://travis-ci.org/sindresorhus/hasha.svg?branch=master)](https://travis-ci.org/sindresorhus/hasha)
16
17 Convenience wrapper around the core [`crypto` Hash class](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) with simpler API and better defaults.
18
19
20 ## Install
21
22 ```
23 $ npm install --save hasha
24 ```
25
26
27 ## Usage
28
29 ```js
30 var hasha = require('hasha');
31
32 hasha('unicorn');
33 //=> 'e233b19aabc7d5e53826fb734d1222f1f0444c3a3fc67ff4af370a66e7cadd2cb24009f1bc86f0bed12ca5fcb226145ad10fc5f650f6ef0959f8aadc5a594b27'
34 ```
35
36 ```js
37 var hasha = require('hasha');
38
39 // hash the process input and output the hash sum
40 process.stdin.pipe(hasha.stream()).pipe(process.stdout);
41 ```
42
43 ```js
44 var hasha = require('hasha');
45
46 // get the MD5 hash of an image
47 hasha.fromFile('unicorn.png', {algorithm: 'md5'}).then(function (hash) {
48         console.log(hash);
49         //=> '1abcb33beeb811dca15f0ac3e47b88d9'
50 });
51 ```
52
53
54 ## API
55
56 See the Node.js [`crypto` docs](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm) for more about hashing.
57
58 ### hasha(input, [options])
59
60 Returns a hash.
61
62 #### input
63
64 Type: `buffer`, `string`, `array` of `string`|`buffer`
65
66 Buffer you want to hash.
67
68 While strings are supported you should prefer buffers as they're faster to hash. Though if you already have a string you should not convert it to a buffer.
69
70 Pass an array instead of concatenating strings and/or buffers. The output is the same, but arrays do not incur the overhead of concatenation.
71
72 #### options
73
74 ##### encoding
75
76 Type: `string`  
77 Default: `hex`  
78 Values: `hex`, `base64`, `buffer`, `binary`
79
80 Encoding of the returned hash.
81
82 ##### algorithm
83
84 Type: `string`  
85 Default: `sha512`  
86 Values: `md5`, `sha1`, `sha256`, `sha512`, etc *([platform dependent](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm))*
87
88 *The `md5` algorithm is good for [file revving](https://github.com/sindresorhus/rev-hash), but you should never use `md5` or `sha1` for anything sensitive. [They're insecure.](http://googleonlinesecurity.blogspot.no/2014/09/gradually-sunsetting-sha-1.html)*
89
90 ### hasha.stream([options])
91
92 Returns a [hash transform stream](https://nodejs.org/api/crypto.html#crypto_class_hash).
93
94 ### hasha.fromStream(stream, [options])
95
96 Returns a promise that resolves to a hash.
97
98 ### hasha.fromFile(filepath, [options])
99
100 Returns a promise that resolves to a hash.
101
102 ### hasha.fromFileSync(filepath, [options])
103
104 Returns a hash.
105
106
107 ## Resources
108
109 - [Hasha: A Friendly Crypto API • DailyJS](http://dailyjs.com/2015/06/12/hasha-a-friendly-crypto-api/)
110
111
112 ## Related
113
114 - [hasha-cli](https://github.com/sindresorhus/hasha-cli) - CLI for this module
115 - [hash-obj](https://github.com/sindresorhus/hash-obj) - Get the hash of an object
116
117
118 ## License
119
120 MIT © [Sindre Sorhus](http://sindresorhus.com)