File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import crypto from 'crypto' ;
22
33function md5 ( bytes ) {
4- if ( typeof Buffer . from === 'function' ) {
5- // Modern Buffer API
6- if ( Array . isArray ( bytes ) ) {
7- bytes = Buffer . from ( bytes ) ;
8- } else if ( typeof bytes === 'string' ) {
9- bytes = Buffer . from ( bytes , 'utf8' ) ;
10- }
11- } else {
12- // Pre-v4 Buffer API
13- if ( Array . isArray ( bytes ) ) {
14- bytes = new Buffer ( bytes ) ;
15- } else if ( typeof bytes === 'string' ) {
16- bytes = new Buffer ( bytes , 'utf8' ) ;
17- }
4+ if ( Array . isArray ( bytes ) ) {
5+ bytes = Buffer . from ( bytes ) ;
6+ } else if ( typeof bytes === 'string' ) {
7+ bytes = Buffer . from ( bytes , 'utf8' ) ;
188 }
199
2010 return crypto
Original file line number Diff line number Diff line change 11import crypto from 'crypto' ;
22
33function sha1 ( bytes ) {
4- if ( typeof Buffer . from === 'function' ) {
5- // Modern Buffer API
6- if ( Array . isArray ( bytes ) ) {
7- bytes = Buffer . from ( bytes ) ;
8- } else if ( typeof bytes === 'string' ) {
9- bytes = Buffer . from ( bytes , 'utf8' ) ;
10- }
11- } else {
12- // Pre-v4 Buffer API
13- if ( Array . isArray ( bytes ) ) {
14- bytes = new Buffer ( bytes ) ;
15- } else if ( typeof bytes === 'string' ) {
16- bytes = new Buffer ( bytes , 'utf8' ) ;
17- }
4+ if ( Array . isArray ( bytes ) ) {
5+ bytes = Buffer . from ( bytes ) ;
6+ } else if ( typeof bytes === 'string' ) {
7+ bytes = Buffer . from ( bytes , 'utf8' ) ;
188 }
199
2010 return crypto
You can’t perform that action at this time.
0 commit comments