INNER CODE UNIT · JavaScript

downloadSha256

agent-sh/agentsys · lib/binary/index.js:243

async function downloadSha256(assetUrl) {
  const sidecarUrl = assetUrl + '.sha256';
  const buf = await downloadToBuffer(sidecarUrl);
  return parseSha256Sidecar(buf.toString('utf8'));
}

/**
 * Compute the lower-case hex SHA-256 of a Buffer.
 * @param {Buffer} buf
 * @returns {string}
 */
function sha256Hex(buf) {
  return crypto.createHash('sha256').update(buf).digest('hex');
}

/**
 * Verify a downloaded buffer against an expected hex digest.
 * Throws with a security-focused message on mismatch.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…