Created
June 1, 2024 03:52
-
-
Save esafak/ba792a7051405f826e32647ae8de7732 to your computer and use it in GitHub Desktop.
Generate hashes for macports from URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Check if a URL is provided | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <url>" | |
exit 1 | |
fi | |
# Get the URL from the command-line argument | |
url="$1" | |
# Create a temporary file | |
temp_file=$(mktemp) | |
# Fetch the file | |
curl -sL "$url" -o "$temp_file" | |
# Get the file size | |
file_size=$(wc -c < "$temp_file") | |
# Calculate hashes | |
rmd160=$(openssl rmd160 "$temp_file" | awk '{print $2}') | |
sha256=$(openssl sha256 "$temp_file" | awk '{print $2}') | |
# Output results | |
echo "RMD160: $rmd160" | |
echo "SHA256: $sha256" | |
echo " Size: $file_size" | |
# Clean up the temporary file | |
rm "$temp_file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment