actions-hugo icon indicating copy to clipboard operation
actions-hugo copied to clipboard

feat: Validate checksum

Open peaceiris opened this issue 6 years ago • 6 comments

async function sha256(str) {
  // Convert string to ArrayBuffer
  const buff = new Uint8Array([].map.call(str, (c) => c.charCodeAt(0))).buffer;
  // Calculate digest
  const digest = await crypto.subtle.digest('SHA-256', buff);
  // Convert ArrayBuffer to hex string
  // (from: https://stackoverflow.com/a/40031979)
  return [].map.call(new Uint8Array(digest), x => ('00' + x.toString(16)).slice(-2)).join('');
}

(async () => {
  const digest = await sha256("hello");
  // 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
})();

SHA256のハッシュをJavaScriptのWeb標準のライブラリだけで計算する - nwtgck / Ryo Ota

wget "https://github.com/gohugoio/hugo/releases/download/v0.58.3/hugo_0.58.3_checksums.txt"
wget "https://github.com/gohugoio/hugo/releases/download/v0.58.3/hugo_0.58.3_macOS-64bit.tar.gz"
grep "hugo_0.58.3_macOS-64bit.tar.gz" "hugo_0.58.3_checksums.txt" | sha256sum --check -

peaceiris avatar Sep 26 '19 03:09 peaceiris

  • ubuntu, macos: | shasum -a 256 --check
  • windows: certutil -hashfile file SHA256

peaceiris avatar Nov 15 '19 02:11 peaceiris

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 15 '20 06:02 github-actions[bot]

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 08 '20 06:03 github-actions[bot]

This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Mar 30 '20 06:03 github-actions[bot]