modif comtabilite
This commit is contained in:
+11
-3
@@ -3,6 +3,7 @@
|
||||
module.exports = Fingerprint;
|
||||
|
||||
var assert = require('assert-plus');
|
||||
var Buffer = require('safer-buffer').Buffer;
|
||||
var algs = require('./algs');
|
||||
var crypto = require('crypto');
|
||||
var errs = require('./errors');
|
||||
@@ -90,7 +91,7 @@ Fingerprint.parse = function (fp, options) {
|
||||
if (!base64RE.test(parts[1]))
|
||||
throw (new FingerprintFormatError(fp));
|
||||
try {
|
||||
hash = new Buffer(parts[1], 'base64');
|
||||
hash = Buffer.from(parts[1], 'base64');
|
||||
} catch (e) {
|
||||
throw (new FingerprintFormatError(fp));
|
||||
}
|
||||
@@ -98,13 +99,20 @@ Fingerprint.parse = function (fp, options) {
|
||||
alg = 'md5';
|
||||
if (parts[0].toLowerCase() === 'md5')
|
||||
parts = parts.slice(1);
|
||||
parts = parts.map(function (p) {
|
||||
while (p.length < 2)
|
||||
p = '0' + p;
|
||||
if (p.length > 2)
|
||||
throw (new FingerprintFormatError(fp));
|
||||
return (p);
|
||||
});
|
||||
parts = parts.join('');
|
||||
/*JSSTYLED*/
|
||||
var md5RE = /^[a-fA-F0-9]+$/;
|
||||
if (!md5RE.test(parts))
|
||||
if (!md5RE.test(parts) || parts.length % 2 !== 0)
|
||||
throw (new FingerprintFormatError(fp));
|
||||
try {
|
||||
hash = new Buffer(parts, 'hex');
|
||||
hash = Buffer.from(parts, 'hex');
|
||||
} catch (e) {
|
||||
throw (new FingerprintFormatError(fp));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user