Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
value: function(algorithm) {
var {ByteString} = require('binary');
var md = java.security.MessageDigest.getInstance(algorithm || 'MD5');
var b = ByteString.wrap(md.digest(this.toByteString()));
var buf = [];
for (var i = 0; i < b.length; i++) {
var j = b[i];
if (j < 16) {
buf[buf.length] = '0';
}
buf[buf.length] = j.toString(16);
}
return buf.join('');
}, writable: true
});
var parseResponse = function (response) {
var b = new ByteString.wrap(response.getContent());
var headers = {};
for (var h in Iterator(response.getHeaders())) {
headers[String(h.getName())] = String(h.getValue());
}
return {
content: b,
finalUrl: String(response.getFinalUrl()),
statusCode: response.getResponseCode(),
headers: headers
}
}
stream.read = function(maxBytes) {
checkClosed();
var result;
if (isFinite(maxBytes)) {
if (maxBytes < 0) {
throw new Error("read(): argument must not be negative");
}
var end = Math.min(position + maxBytes, length);
result = ByteString.wrap(buffer.slice(position, end));
position = end;
return result;
} else {
result = ByteString.wrap(buffer.slice(position, length));
position = length;
}
return result;
};
function digest(body) {
const md = java.security.MessageDigest.getInstance("MD5");
body.forEach(function(part) {
md.update(part);
});
return strings.b16encode(ByteString.wrap(md.digest()));
}
stream.read = function(num) {
checkClosed();
var result;
if (isFinite(num)) {
if (num < 0) {
throw new Error("read(): argument must not be negative");
}
var end = Math.min(position + num, length);
result = ByteString.wrap(buffer.slice(position, end));
position = end;
return result;
} else {
result = ByteString.wrap(buffer.slice(position, length));
position = length;
}
return result;
};