Last change
on this file since e29cc2e was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago |
primeNG components
|
-
Property mode
set to
100644
|
File size:
576 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var crypto = require('crypto');
|
---|
4 |
|
---|
5 | function md5(bytes) {
|
---|
6 | if (typeof Buffer.from === 'function') {
|
---|
7 | // Modern Buffer API
|
---|
8 | if (Array.isArray(bytes)) {
|
---|
9 | bytes = Buffer.from(bytes);
|
---|
10 | } else if (typeof bytes === 'string') {
|
---|
11 | bytes = Buffer.from(bytes, 'utf8');
|
---|
12 | }
|
---|
13 | } else {
|
---|
14 | // Pre-v4 Buffer API
|
---|
15 | if (Array.isArray(bytes)) {
|
---|
16 | bytes = new Buffer(bytes);
|
---|
17 | } else if (typeof bytes === 'string') {
|
---|
18 | bytes = new Buffer(bytes, 'utf8');
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | return crypto.createHash('md5').update(bytes).digest();
|
---|
23 | }
|
---|
24 |
|
---|
25 | module.exports = md5;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.