Linux Lite 8.0 RC1 has been released - Click here


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

A simple way to check MD5sum
#11

This is great misko! Would it be possible to add the ability to choose MD5 or Sha1?
Reply
#12

Possible, but I keep it in the right-click menu

Name: SHA1
Description: Calculates SHA1 sum.
Command: /usr/scripts/sha1 %f
Pattern: *
Files: Check all the boxes except Directories
save the script as sha1
make executable
copy the file to /usr/scripts

Code:
#!/bin/bash

sha1_file="$@"

# Start sha1sum of a selected file
sha1sum "$sha1_file" | tee >(cut -d ' ' -f1 > /tmp/sumsh1) |zenity --progress --title="SHA1" --text="Calculating sha1sum for:\n${sha1_file##*/}" --pulsate --auto-close

# If Cancel is clicked then remove temporary file and exit
if [ "${PIPESTATUS[2]}" -ne "0" ]; then
rm /tmp/sumsh1
exit 0
fi

# Display calculated md5sum
sum=`cat /tmp/sumsh1`
zenity --info --title="SHA1" --text="SHA1sum : $sum\nFile :          ${sha1_file##*/}"
rm /tmp/sumsh1

And md5sum

Name: MD5
Description: Calculates MD5 sum.
Command: /usr/scripts/md5 %f
Pattern: *
Files: Check all the boxes except Directories
save the script as md5
make executable
copy the file to /usr/scripts
Code:
#!/bin/bash

md5_file="$@"

# Start MD5sum of a selected file
md5sum "$md5_file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="MD5sum" --text="Calculating md5sum for:\n${md5_file##*/}" --pulsate --auto-close

# If Cancel is clicked then remove temporary file and exit
if [ "${PIPESTATUS[2]}" -ne "0" ]; then
rm /tmp/sum
exit 0
fi

# Display calculated md5sum
sum=`cat /tmp/sum`
zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile :          ${md5_file##*/}"
# echo $sum > "$md5_file".md5sum
rm /tmp/sum
It's better to use * as a pattern because that way you can calculate the sum of any file.

P.S. I hope this version works for rokytnji. :)
Reply
#13

Thank you! Do you think it might be better as a single script where you select which Checksum to verify? I imagine a dialog pops up where the user can choose SHA1 or MD5.
Reply
#14

(12-06-2014, 03:38 PM)mlsmith link Wrote:  Do you think it might be better as a single script where you select which Checksum to verify? I imagine a dialog pops up where the user can choose SHA1 or MD5.
Hmm, great idea. :)  Thank you. I'll set md5 as default one and add SHA256.
Once it's ready, I'll post here.
Reply
#15

Here it is:
[Image: eXjC9Qh.png]

Name: Checksum
Description: Calculates  checksum.
Command: /usr/scripts/checksum %f
Pattern: *
Appearance: Check all the boxes except Directories

save the script as checksum
make executable
copy the file to /usr/scripts

Code:
#!/bin/bash
# Misko_2083

file="$@"

MD5=(`echo "" | awk '{print "TRUE","MD5", $0}'`)
SHA1=(`echo "" | awk '{print "FALSE","SHA-1", $0}'`)
SHA224=(`echo "" | awk '{print "FALSE","SHA-224", $0}'`)
SHA256=(`echo "" | awk '{print "FALSE","SHA-256", $0}'`)
SHA384=(`echo "" | awk '{print "FALSE","SHA-384", $0}'`)
SHA512=(`echo "" | awk '{print "FALSE","SHA-512", $0}'`)

selection=$(zenity --list --radiolist --height=300 --title="Checksum" --text="File:  <b>${file##*/}</b>\nPick the hash algorithm." --column="Pick" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")

# If Quit is clicked then exit
if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    exit 0
fi

echo $selection | grep "MD5" > /dev/null
if [ $? = 0 ];then
    md5sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="MD5sum" --text="Calculating MD5 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="MD5sum" --text="MD5sum : $sum\nFile :          ${file##*/}"
    rm /tmp/sum
    exit 0
fi

echo $selection | grep "SHA-1" > /dev/null
if [ $? = 0 ];then
    sha1sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-1" --text="Calculating SHA-1 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="SHA-1" --text="SHA-1: $sum\nFile :    ${file##*/}"
    rm /tmp/sum
    exit 0
fi

echo $selection | grep "SHA-224" > /dev/null
if [ $? = 0 ];then
    sha224sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-224" --text="Calculating SHA-224 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="SHA-224" --text="SHA-224 : $sum\nFile :         ${file##*/}"
    rm /tmp/sum
    exit 0
fi

echo $selection | grep "SHA-256" > /dev/null
if [ $? = 0 ];then
    sha256sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-256" --text="Calculating SHA-256 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="SHA-256" --text="SHA-256 : $sum\nFile :         ${file##*/}"
    rm /tmp/sum
    exit 0
fi

echo $selection | grep "SHA-384" > /dev/null
if [ $? = 0 ];then
    sha384sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-384" --text="Calculating SHA-384 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="SHA-384" --text="SHA-384 : $sum\nFile :         ${file##*/}"
    rm /tmp/sum
    exit 0
fi

echo $selection | grep "SHA-512" > /dev/null
if [ $? = 0 ];then
    sha512sum "$file" | tee >(cut -d ' ' -f1 > /tmp/sum) |zenity --progress --title="SHA-512" --text="Calculating SHA-512 for:\n${file##*/}" --pulsate --auto-close

    # If Cancel is clicked then remove temporary file and exit
    if [ "${PIPESTATUS[2]}" -ne "0" ]; then
        rm /tmp/sum
        exit 0
    fi

    sum=`cat /tmp/sum`
    zenity --info --title="SHA-512" --text="SHA-512 : $sum\nFile :         ${file##*/}"
    rm /tmp/sum
    exit 0
fi
Reply
#16

Outstanding! Thanks so much misko.
Reply
#17

You're welcome so much. :)
Reply
#18

Wow!  Excellent job misko_2083!

Just loaded it on my LL 2.0 desktop -- works great.

Try Linux Beginner Search Engine for answers to Linux questions.
Reply
#19

I think I need a sub menu in my right-click menu for all of misko's and Jerry's scripts.  ;)
Reply
#20

(12-07-2014, 05:04 PM)gold_finger link Wrote:  Wow!  Excellent job misko_2083!

Just loaded it on my LL 2.0 desktop -- works great.
Thanks. It was mlsmith's idea to merge the scripts.
(12-07-2014, 09:14 PM)mlsmith link Wrote:  I think I need a sub menu in my right-click menu for all of misko's and Jerry's scripts.  ;)
Or, you could modify my script and add all of right-click menu items in a list. ;)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)