Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Validate checksum #51

Open
peaceiris opened this issue Sep 26, 2019 · 6 comments
Open

feat: Validate checksum #51

peaceiris opened this issue Sep 26, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@peaceiris
Copy link
Owner

peaceiris commented Sep 26, 2019

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 peaceiris added the enhancement New feature or request label Sep 26, 2019
@peaceiris peaceiris self-assigned this Oct 7, 2019
@peaceiris
Copy link
Owner Author

@peaceiris
Copy link
Owner Author

@peaceiris
Copy link
Owner Author

peaceiris commented Nov 15, 2019

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

@github-actions github-actions bot added the Stale label Dec 6, 2019
@peaceiris peaceiris removed the Stale label Dec 6, 2019
@github-actions github-actions bot added the Stale label Dec 28, 2019
@peaceiris peaceiris removed the Stale label Dec 28, 2019
Repository owner deleted a comment from github-actions bot Jan 17, 2020
Repository owner deleted a comment from github-actions bot Jan 17, 2020
@peaceiris peaceiris changed the title Feat: Validate checksum feat: Validate checksum Jan 25, 2020
@github-actions
Copy link

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 github-actions bot added the Stale label Feb 15, 2020
@peaceiris peaceiris removed the Stale label Feb 15, 2020
@github-actions
Copy link

github-actions bot commented Mar 8, 2020

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 github-actions bot added the Stale label Mar 8, 2020
@peaceiris peaceiris removed the Stale label Mar 8, 2020
@github-actions
Copy link

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 github-actions bot added the Stale label Mar 30, 2020
@peaceiris peaceiris removed the Stale label Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant