From 046d9aa2432b3a6241d73c3684ef4e512974b594 Mon Sep 17 00:00:00 2001 From: Markson Hon <50002150+MarksonHon@users.noreply.github.com> Date: Mon, 16 Jan 2023 21:51:45 +0800 Subject: [PATCH] Fix hash check --- install-release.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/install-release.sh b/install-release.sh index db0fbdf..9cdd95b 100644 --- a/install-release.sh +++ b/install-release.sh @@ -429,14 +429,12 @@ download_xray() { fi # Verification of Xray archive - for LISTSUM in 'md5' 'sha1' 'sha256' 'sha512'; do - SUM="$(${LISTSUM}sum "$ZIP_FILE" | sed 's/ .*//')" - CHECKSUM="$(grep ${LISTSUM^^} "$ZIP_FILE".dgst | grep "$SUM" -o -a | uniq)" - if [[ "$SUM" != "$CHECKSUM" ]]; then - echo 'error: Check failed! Please check your network or try again.' - return 1 - fi - done + CHECKSUM=$(cat "$ZIP_FILE".dgst | awk -F '= ' '/256=/ {print $2}') + LOCALSUM=$(sha256sum "$ZIP_FILE" | awk '{printf $1}') + if [[ "$CHECKSUM" != "$LOCALSUM" ]]; then + echo 'error: SHA256 check failed! Please check your network or try again.' + return 1 + fi } decompression() {