Skip to content

Instantly share code, notes, and snippets.

@esafak
Created June 1, 2024 03:52
Show Gist options
  • Save esafak/ba792a7051405f826e32647ae8de7732 to your computer and use it in GitHub Desktop.
Save esafak/ba792a7051405f826e32647ae8de7732 to your computer and use it in GitHub Desktop.
Generate hashes for macports from URL
#!/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