Skip to content

Commit c70080c

Browse files
committed
Add notes about SHA1/MD5 security to Readme
1 parent f214c5f commit c70080c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

readme.markdown

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ For more information, see [this discussion](https://github.com/puleos/object-has
3131
## hash(value, options);
3232
Generate a hash from any object or type. Defaults to sha1 with hex encoding.
3333
* `algorithm` hash algo to be used: 'sha1', 'md5'. default: sha1
34+
* This supports the algorithms returned by `crypto.getHashes()`. Note that the default of SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
3435
* `excludeValues` {true|false} hash object keys, values ignored. default: false
3536
* `encoding` hash encoding, supports 'buffer', 'hex', 'binary', 'base64'. default: hex
3637
* `ignoreUnknown` {true|*false} ignore unknown object types. default: false
@@ -44,11 +45,13 @@ Generate a hash from any object or type. Defaults to sha1 with hex encoding.
4445
* `unorderedSets` {true|false} Sort `Set` and `Map` instances before hashing, i.e. make
4546
`hash(new Set([1, 2])) == hash(new Set([2, 1]))` return `true`. default: true
4647
* `unorderedObjects` {true|false} Sort objects before hashing, i.e. make `hash({ x: 1, y: 2 }) === hash({ y: 2, x: 1 })`. default: true
47-
* `excludeKeys` optional function for exclude specific key(s) from hashing, if returns true then exclude from hash. default: include all keys
48+
* `excludeKeys` optional function for exclude specific key(s) from hashing, if returns true then exclude from hash. default: include all keys
4849

4950
## hash.sha1(value);
5051
Hash using the sha1 algorithm.
5152

53+
Note that SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
54+
5255
*Sugar method, equivalent to hash(value, {algorithm: 'sha1'})*
5356

5457
## hash.keys(value);
@@ -59,11 +62,15 @@ Hash object keys using the sha1 algorithm, values ignored.
5962
## hash.MD5(value);
6063
Hash using the md5 algorithm.
6164

65+
Note that the MD5 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
66+
6267
*Sugar method, equivalent to hash(value, {algorithm: 'md5'})*
6368

6469
## hash.keysMD5(value);
6570
Hash object keys using the md5 algorithm, values ignored.
6671

72+
Note that the MD5 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
73+
6774
*Sugar method, equivalent to hash(value, {algorithm: 'md5', excludeValues: true})*
6875

6976
## hash.writeToStream(value, [options,] stream):
@@ -85,8 +92,8 @@ browser: */dist/object_hash.js*
8592
<script src="object_hash.js" type="text/javascript"></script>
8693
8794
<script>
88-
var hash = objectHash.sha1({foo:'bar'});
89-
95+
var hash = objectHash.sha1({foo:'bar'});
96+
9097
console.log(hash); // e003c89cdf35cdf46d8239b4692436364b7259f9
9198
</script>
9299
```
@@ -143,7 +150,7 @@ hash(bob, { algorithm: 'md5', encoding: 'base64' });
143150
```
144151

145152
## Legacy Browser Support
146-
IE <= 8 and Opera <= 11 support dropped in version 0.3.0. If you require
153+
IE <= 8 and Opera <= 11 support dropped in version 0.3.0. If you require
147154
legacy browser support you must either use an ES5 shim or use version 0.2.5
148155
of this module.
149156

0 commit comments

Comments
 (0)