From b4035a8eb2e191973cbfbebf9b17fb118c271dc0 Mon Sep 17 00:00:00 2001 From: Markson Hon <50002150+MarksonHon@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:13:38 +0800 Subject: [PATCH] Fix hash check (#263) * Fix hash check * chore Co-authored-by: Markson Co-authored-by: IceCodeNew <32576256+IceCodeNew@users.noreply.github.com> --- install-release.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/install-release.sh b/install-release.sh index 52f76bf..72c4077 100644 --- a/install-release.sh +++ b/install-release.sh @@ -302,14 +302,12 @@ download_v2ray() { fi # Verification of V2Ray 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=$(awk -F '= ' '/256=/ {print $2}' < "${ZIP_FILE}.dgst") + 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() {