use if sha256 instead md5

This commit is contained in:
maryamsaleem 2025-02-06 15:11:27 +05:00
parent 70d1d9a964
commit 5e0f7452a7

View file

@ -372,9 +372,9 @@ exports.constructAuthorizedRequest = function (request, username, password, prox
nonce: proxyAuthenticateHeader.nonce.replace(/"/g, ""),
};
// Construct Digest authentication header manually
const ha1 = crypto.createHash("md5").update(`${username}:${digestChallenge.realm}:${password}`).digest("hex");
const ha2 = crypto.createHash("md5").update(`${request.method}:${request.uri}`).digest("hex");
const response = crypto.createHash("md5").update(`${ha1}:${digestChallenge.nonce}:${ha2}`).digest("hex");
const ha1 = crypto.createHash("sha256").update(`${username}:${digestChallenge.realm}:${password}`).digest("hex");
const ha2 = crypto.createHash("sha256").update(`${request.method}:${request.uri}`).digest("hex");
const response = crypto.createHash("sha256").update(`${ha1}:${digestChallenge.nonce}:${ha2}`).digest("hex");
const authorizationHeader = `Digest username="${username}", realm="${digestChallenge.realm}", nonce="${digestChallenge.nonce}", uri="${request.uri}", response="${response}"`;
const authorizedRequest = {
...request,