summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/uuid/lib/md5.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/uuid/lib/md5.js')
-rw-r--r--deps/npm/node_modules/uuid/lib/md5.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/deps/npm/node_modules/uuid/lib/md5.js b/deps/npm/node_modules/uuid/lib/md5.js
new file mode 100644
index 0000000000..7044b872f5
--- /dev/null
+++ b/deps/npm/node_modules/uuid/lib/md5.js
@@ -0,0 +1,25 @@
+'use strict';
+
+var crypto = require('crypto');
+
+function md5(bytes) {
+ if (typeof Buffer.from === 'function') {
+ // Modern Buffer API
+ if (Array.isArray(bytes)) {
+ bytes = Buffer.from(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = Buffer.from(bytes, 'utf8');
+ }
+ } else {
+ // Pre-v4 Buffer API
+ if (Array.isArray(bytes)) {
+ bytes = new Buffer(bytes);
+ } else if (typeof bytes === 'string') {
+ bytes = new Buffer(bytes, 'utf8');
+ }
+ }
+
+ return crypto.createHash('md5').update(bytes).digest();
+}
+
+module.exports = md5;