Linux Lite Forums

Software - Support => Tutorials => Topic started by: anon222 on August 19, 2014, 08:59:49 PM

Title: A simple way to check MD5sum
Post by: anon222 on August 19, 2014, 08:59:49 PM
1. Open the Thunar file manager
2. Click on Edit and then on Configure custom actions
3. Add A new custom action by clicking on a '+' button
4. Enter this in the text boxes:
Name: Check MD5
Description: Computes MD5 checksum for the selected file.
Command:
Code: [Select]
zenity --info --title="Check MD5 for %n" --text="$(md5sum %f)"Icon: You can skip this or choose your the icon of your choice. I've setup a calculator icon.
5. Click on Appearance Conditions tab
6. In the File pattern enter:
Code: [Select]
*.iso;*.ISO;*.img;*.IMG7. Check all boxes except Directories and confirm by clicking on OK
If you have an .iso or .img file on the Desktop you will have to log out and back in to be able to use this.
Now you can right-click on .iso or .img file and Check MD5.
Title: Re: A simple way to check MD5sum
Post by: Jerry on August 19, 2014, 09:07:48 PM
Another beauty, I might even add this to the next Linux Lite :)
Title: Re: A simple way to check MD5sum
Post by: rokytnji on August 19, 2014, 10:30:12 PM
Code: [Select]
$ apt-cache policy zenity
zenity:
  Installed: 3.8.0-1ubuntu1
  Candidate: 3.8.0-1ubuntu1
  Version table:
 *** 3.8.0-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages
        100 /var/lib/dpkg/status

Looks like I will do this since zenity comes with the install already.

Nice How to. Thanks. Edit: Done and Done. You might want to edit "Description: Cumputes MD5 checksum for the selected file." to Description: Computes MD5 checksum for the selected file.

Code: [Select]
~$ ls
Comics   Documents  Icons   Isos   Pictures  Screeny  Templates  Wallpapers
Desktop  Downloads  Images  Music  Public    Scripts  Videos

PS. I appreciate work like this because I have myself done work like this.

http://antix.freeforums.org/antix-11-eeepc-900-install-finished-t3104.html

So when I say thanks. It comes from a compadre.
Title: Re: A simple way to check MD5sum
Post by: anon222 on August 20, 2014, 05:11:14 AM
Another beauty, I might even add this to the next Linux Lite :)
Thanks Valtam. I wasn't sure should I post this as a tutorial or a suggestion. It would be great to see that in the next LL.  :)
Nice How to. Thanks. Edit: Done and Done. You might want to edit "Description: Cumputes MD5 checksum for the selected file." to Description: Computes MD5 checksum for the selected file.
I mistyped that one, thank you. :)
PS. I appreciate work like this because I have myself done work like this.

http://antix.freeforums.org/antix-11-eeepc-900-install-finished-t3104.html

So when I say thanks. It comes from a compadre.

Thanks compadre. :)
Title: Re: A simple way to check MD5sum
Post by: anon222 on October 10, 2014, 09:42:25 AM
I've improved this.
save this script to /usr/scripts
name it md5
Code: [Select]
#!/bin/bash

md5_file="$1"

# 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##*/}"
rm /tmp/sum

Name: Check MD5
Description: Computes MD5 checksum for the selected file.
Command:
Code: [Select]
/usr/scripts/md5 %f--------------------------------------------------------------
File pattern:
Code: [Select]
*.iso;*.ISO;*.img;*.IMGCheck all boxes except Directories
Title: Re: A simple way to check MD5sum
Post by: rokytnji on October 10, 2014, 10:54:30 AM
Hey Bro. Trying it out. I am missing a step for sure. I get check md5 on right click but nothing happens.
You know. Problem between keyboard and user. As usual.

Code: [Select]
harry@biker1:~$ cat /usr/scripts/md5

md5_file="$1"

# 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##*/}"
rm /tmp/sum
harry@biker1:~$

(http://thumbnails110.imagebam.com/35685/af3205356842561.jpg) (http://www.imagebam.com/image/af3205356842561) (http://thumbnails109.imagebam.com/35685/75e0a9356842576.jpg) (http://www.imagebam.com/image/75e0a9356842576) (http://thumbnails111.imagebam.com/35685/c296c4356842592.jpg) (http://www.imagebam.com/image/c296c4356842592)

While in "gksu thunar" /( root thunar file manager). I made the md5 sum text file executable via right click. I also logged in and out a few times.
But no joy bro. I can md5sum through terminal just fine as always. Just playing with your stuff to test out.
Maybe a permissions issue?
Title: Re: A simple way to check MD5sum
Post by: anon222 on October 10, 2014, 11:36:18 AM
Hi rokytnji, you must make the script executable
I missed to mention that step. :)
Oh I see. :)
You made the owner root
switch it to harry
Code: [Select]
sudo chown -R harry /usr/scripts/md5
Title: Re: A simple way to check MD5sum
Post by: rokytnji on October 10, 2014, 01:00:33 PM
Ok. Did That. Though I wonder if maybe it should be

Code: [Select]
sudo chown -R harry:harry /usr/scripts/md5
Because she still won't open . Let me check something. I do not feel like rebooting yet. I might be screwing up because of 2 Linux-Lite 2.0 installs on 2 different laptops.

Code: [Select]
~$ apt-cache policy zenity
zenity:
  Installed: 3.8.0-1ubuntu1
  Candidate: 3.8.0-1ubuntu1
  Version table:
 *** 3.8.0-1ubuntu1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/main i386 Packages
        100 /var/lib/dpkg/status

No. That aint it. Here is relevant info

Code: [Select]
harry@biker1:~$ ls -l /usr/scripts/md5
-rwxrwxr-x 1 harry root 479 Oct 10 09:16 /usr/scripts/md5

and for double check before I posted. I did
Code: [Select]
harry@biker1:~$ sudo chmod +x /usr/scripts/md5
[sudo] password for harry:
harry@biker1:~$

and logged in and out again to be double sure also.
But nothing opens on my md5 right click thunar custom action on ~/isos/puppy/what ever iso I right click on.
Maybe I am in a bad spot of the universe? :o

Edit: Just in the off chance

Code: [Select]
sudo chmod a+x /usr/scripts/md5
plus a reboot gave no positive results either. At least one cannot say I aint trying.  :D
Title: Re: A simple way to check MD5sum
Post by: anon222 on October 11, 2014, 01:19:25 PM
It's woking here :)
https://www.youtube.com/watch?v=m9oTyvhE-MY&feature=youtu.be
I made this other script, but it's not for thunar custom action.
This script opens a dialog and then you choose a file.
Code: [Select]
#!/bin/bash

# Set the default directory for the file selection dialog
cd $HOME/Downloads

# Select a file
md5_file=(`zenity --title="MD5sum" --file-selection --file-filter="*.iso *.ISO *.img *.IMG"`)

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

# 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##*/}"
# If you want to make  an md5sum file, uncheck the next line
# echo $sum > "$md5_file".md5sum
rm /tmp/sum
Title: Re: A simple way to check MD5sum
Post by: rokytnji on October 11, 2014, 01:39:53 PM
Cool. I am compiling urbanlightscape-1.3.3 (http://www.indii.org/software/urbanlightscape/) at the moment.

Then try checkinstall instead of makeinstall like you mentioned before in the vlc thread.
I don't know where I screwed up using your instructions but I know the problem is with me.
No biggy as I md5sum check through terminal anyways.
As you see from my previous posts.
I am a loosy goosy, not afeared, linux user.
I am always experimenting. customising myself.

For anyone reading this. Tintii does about the same thing as urban lightscape does and it is in Linux-Lite synaptic package manager.

Code: [Select]
harry@biker1:~$ apt-cache policy tintii
tintii:
  Installed: 2.8.2-1
  Candidate: 2.8.2-1
  Version table:
 *** 2.8.2-1 0
        500 http://us.archive.ubuntu.com/ubuntu/ trusty/universe i386 Packages
        100 /var/lib/dpkg/status

I am just doing the urban lightscape for practice and grins.

Edit: At least checkinstall worked out for me. My description was short and sweet . Photo editor like in photoshop. I did not create a installed doc. file though since it said generic and this .deb is only for me/myself/and I.

Code: [Select]
harry@biker1:~/Downloads/urbanlightscape-1.3.3$ ls
aclocal.m4     configure.ac     install-sh   src
autogen.sh     COPYING          Makefile     urbanlightscape
autotools      depcomp          Makefile.am  urbanlightscape_1.3.3-1_i386.deb
config.log     description-pak  Makefile.in
config.status  help             missing
configure      images           README
harry@biker1:~/Downloads/urbanlightscape-1.3.3$ apt-cache policy urbanlightscape
urbanlightscape:
  Installed: 1.3.3-1
  Candidate: 1.3.3-1
  Version table:
 *** 1.3.3-1 0
        100 /var/lib/dpkg/status

(http://thumbnails111.imagebam.com/35721/778258357204111.jpg) (http://www.imagebam.com/image/778258357204111)
Title: Re: A simple way to check MD5sum
Post by: Mike on December 05, 2014, 10:25:46 PM
This is great misko! Would it be possible to add the ability to choose MD5 or Sha1?
Title: Re: A simple way to check MD5sum
Post by: anon222 on December 06, 2014, 01:25:32 AM
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: [Select]
#!/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: [Select]
#!/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. :)
Title: Re: A simple way to check MD5sum
Post by: Mike on December 06, 2014, 10:38:11 AM
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.
Title: Re: A simple way to check MD5sum
Post by: anon222 on December 06, 2014, 09:13:03 PM
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.
Title: Re: A simple way to check MD5sum
Post by: anon222 on December 07, 2014, 04:33:53 AM
Here it is:
(http://i.imgur.com/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: [Select]
#!/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

Title: Re: A simple way to check MD5sum
Post by: Mike on December 07, 2014, 08:17:30 AM
Outstanding! Thanks so much misko.
Title: Re: A simple way to check MD5sum
Post by: anon222 on December 07, 2014, 09:07:14 AM
You're welcome so much. :)
Title: Re: A simple way to check MD5sum
Post by: gold_finger on December 07, 2014, 12:04:30 PM
Wow!  Excellent job misko_2083!

Just loaded it on my LL 2.0 desktop -- works great.
Title: Re: A simple way to check MD5sum
Post by: Mike on December 07, 2014, 04:14:31 PM
I think I need a sub menu in my right-click menu for all of misko's and Jerry's scripts.  ;)
Title: Re: A simple way to check MD5sum
Post by: anon222 on December 08, 2014, 10:02:32 PM
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.
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. ;)
Title: Re: A simple way to check MD5sum
Post by: bitsnpcs on January 14, 2017, 12:56:18 PM
When changing from Windows to Linux Lite, you can in Windows use, WinMD5 free, to verify the download.
Title: Re: A simple way to check MD5sum
Post by: firenice03 on January 14, 2017, 02:27:39 PM
If Vista and newer - Powershell should be installed by default, you can run the below command to check the MD5 checksum.. May alleviate the need to download a tool so you can dive right into a LL install  8) LOL

Its in tutorials as well: https://www.linuxliteos.com/forums/tutorials/md5-checksum-for-windows/msg22470/#msg22470

Command to paste into Powershell:
Code: [Select]
if ( $($(CertUtil -hashfile C:PATH_to_FILE\File_name.iso MD5)[1] -replace " ","") -eq "PASTE_HASH_between_quotes" ) { echo "ok" }
C:PATH_to_FILE\File_name.iso -- The full path and the .iso file
"PASTE_HASH_between_quotes" -- Paste the supplied hash

If the hash checks out it returns an ok.. If not it will be blank...
Title: Re: A simple way to check MD5sum
Post by: bitsnpcs on January 14, 2017, 06:51:50 PM
Appreciate the help. Unsure why is not default on Windows 10 for me. So I had used the tool.





Title: Re: A simple way to check MD5sum
Post by: ralphy on April 03, 2017, 10:49:42 AM

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

I find the script rather useful. I've modified it to allow users to select a file just by launching the script. If the custom action in Thunar is configured, it will allow users to right-click and select files without prompting to browse for the file.

Extract and move the extracted files to their respective locations.

/usr/scripts/checksum
/usr/share/applications/checksum.desktop

Here is what it looks like:

(http://i.imgur.com/mVZxS0C.png)

(http://i.imgur.com/I1HNS17.png)

(http://i.imgur.com/bjIYcAt.png)

(http://i.imgur.com/1JTLorM.png)

(http://i.imgur.com/7sKrZU4.png)

Cheers!


Code: [Select]
#!/bin/bash
# Misko_2083, Ralphy
ic="/usr/share/icons/Faenza/actions/32/system-run.png"
# user selected file
file="$@"
if [ -z "$@" ]; then szPath=$(zenity --file-selection --title="Checksum - Select file..." --file-filter='Image files (ISO,IMG) | *.iso *.ISO *.img *.IMG' --file-filter='All files | *');
if [ "$?" -eq "1" ]; then exit 0; else file="$szPath"; fi; fi
while (true); do
MD5=(`echo "" | awk '{print "md5sum","✍","MD5", $0}'`); SHA1=(`echo "" | awk '{print "sha1sum","✍","SHA-1", $0}'`)
SHA224=(`echo "" | awk '{print "sha224sum","✍","SHA-224", $0}'`); SHA256=(`echo "" | awk '{print "sha256sum","✍","SHA-256", $0}'`)
SHA384=(`echo "" | awk '{print "sha384sum","✍","SHA-384", $0}'`); SHA512=(`echo "" | awk '{print "sha512sum","✍","SHA-512", $0}'`)
# main dialog
selected=$(zenity --list --width=180 --height=248 --window-icon="$ic" --hide-header --title=" Checksum" --text="File:  <b>${file##*/}</b>\n\nSelect the Hash algorithm\n" \
--hide-column="1" --separator="," --print-column="1,3" --column="Checksum" --column="" --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")
# If Quit is clicked then exit
if [ "${PIPESTATUS[0]}" -ne "0" ]; then exit 0; fi
# read selection and split it
checksum=$(awk -F, '{print $1}' <<<$selected)
dialog=$(awk -F, '{print $2}' <<<$selected)
if [ "$checksum" == "" ]; then zenity --warning --window-icon="warning" --text="\nNo Hash algorithm was selected. Please try again. " --timeout="3"; continue; else :; fi
# temp sum file
TMPF="/tmp/sum"
# common function - if cancel then remove $TMPF and exit
action_cancel() { if [ "${PIPESTATUS[2]}" -ne "0" ]; then rm $TMPF; exit 0; fi }
action_sum() { sum=`cat $TMPF`; zenity --info --title="$dialog" --text="\nFile:<b> ${file##*/} </b>\n\n$dialog: $sum"; rm -f $TMPF & exit 0; }
"$checksum" "$file" | tee >(cut -d ' ' -f1 > $TMPF) |zenity --window-icon="info" --width=240 --progress --title="$dialog" --text="File:<b> ${file##*/} </b>\n\n- Calculating $dialog. Please wait..." --pulsate --auto-close
action_cancel
action_sum
done
exit
Title: Re: A simple way to check MD5sum
Post by: Vera on May 31, 2017, 07:26:55 AM
That's an exciting way of adding it to a GUI through Thunar.

On LinuxLite, when I've needed to check MD5 (or other hash sums) I've just gone for a simple approach and used the command line with the built-in md5sum function (or sha1sum or sha256sum depending what function I want to use). It has worked well for me when checking copied or downloaded ISO's against original. I haven't used it for anything more advanced than that though.

I do like the addition to Thunar that you mentioned since it would allow the function to always just "be there" as an option for doing checksum of any file via GUI, which definitely is helpful. Thanks for the tutorial.
Title: Re: A simple way to check MD5sum
Post by: ralphy on May 31, 2017, 09:53:36 AM
@Vera


A month ago (https://github.com/ralphys/checksum) I switched the script to yad. I will add it to my repo so it can be easily installed. It creates the Thunar contextual menu option on install too and adds an option to copy the final sum to clipboard.


(http://i.imgur.com/3bC9YeY.png)
Title: Re: A simple way to check MD5sum
Post by: tuto on September 05, 2018, 08:40:49 PM
Hi, community.

@misko_2083 and @ralphy,  this is great script. Thank you.

I do known not much about shell scripting, but I modify this checksum script for hash check, such as in gtkhash application.

Any improvement is welcome.

I am sorry by bad English language use; I am learning, yet..

Code: [Select]
#!/bin/bash

# Autors: Misko_2083, Ralphy
# Tomado desde: https://www.linuxliteos.com/forums/tutorials/a-simple-way-to-check-md5sum/15/
# Adapted by : tuto
#
# #####################################################################

# Images
ic="/usr/share/icons/Faenza/actions/32/system-run.png"

# ### User selected file.
file="$@"
if [ -z "$@" ]; then
   szPath=$(zenity --file-selection --title="Checksum - Select file..." --file-filter='Image files (ISO,IMG) | *.iso *.ISO *.img *.IMG' --file-filter='All files | *')
     if [ "$?" -eq "1" ]; then
      exit 0
   else
      file="$szPath"
   fi
fi

while (true); do
   MD5=(`echo "" | awk '{print "md5sum","✍","MD5", $0}'`)
   SHA1=(`echo "" | awk '{print "sha1sum","✍","SHA-1", $0}'`)
   SHA224=(`echo "" | awk '{print "sha224sum","✍","SHA-224", $0}'`)
   SHA256=(`echo "" | awk '{print "sha256sum","✍","SHA-256", $0}'`)
   SHA384=(`echo "" | awk '{print "sha384sum","✍","SHA-384", $0}'`)
   SHA512=(`echo "" | awk '{print "sha512sum","✍","SHA-512", $0}'`)
   # ### Main dialog.
   selected=$(zenity --list --width=180 --height="248" --window-icon="$ic" --hide-header --title=" Checksum" \
                                    --text="File:  <b>${file##*/}</b>\n\nSelect the Hash algorithm\n" --hide-column="1" --separator=","  \
                                    --print-column="1,3" \
                                    --column="Checksum" \
                                    --column="" \
                                    --column="Hash" "${MD5[@]}" "${SHA1[@]}" "${SHA224[@]}" "${SHA256[@]}" "${SHA384[@]}" "${SHA512[@]}")
   # ### If quit is clicked then exit.
   if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      exit 0
   fi
   # ### Read selection and split it.
   checksum=$(awk -F, '{print $1}' <<<$selected)
   dialog=$(awk -F, '{print $2}' <<<$selected)
   if [ "$checksum" == "" ]; then
      zenity --warning --window-icon="warning" --text="\nNo Hash algorithm was selected. Please, try again. " --timeout="3"; continue
   else
      :
   fi
   # ### Temp sum file.
    TMPF="/tmp/sum"
    # ### Common function - If cancel then remove $TMPF and exit.
    action_cancel() { if [ "${PIPESTATUS[2]}" -ne "0" ]; then
                                      rm $TMPF; exit 0
                                   fi
                                 }
    action_sum() { sum=`cat $TMPF`; zenity --info --title="$dialog" --text="\nFile:<b> ${file##*/} </b>\n\n$dialog: $sum" --ok-label="Ok"; rm -f $TMPF
                            }
    action_compare() { zenity --question --window-icon="$ic" --title="Hash Check" --text="You want verify the calculated hash?" --cancel-label="No" --ok-label="Yes"
                                       if [ "$?" != "0" ]; then
                                          exit 0
                                       else
                                          ctrlsum=`zenity --entry --window-icon="$ic" --title="Hash Check" --text="Enter a control sum value" --cancel-label="Close" --ok-label="Ok"`;
                                          if [ "$ctrlsum" != "" ] && [ "$ctrlsum" == "$sum" ]; then
                                             zenity --info --window-icon="$ic" --title="Hash Check" --text="<b>Checksum</b> is correct.\nThe file is complete."
                                          elif [ "$ctrlsum" != "" ] && [ "$ctrlsum" != "$sum" ]; then
                                                zenity --error --title="Hash Check" --text="<b>Checksum no match</b>.\nThe file is incomplete or corrupt."; continue
                                          else
                                                exit 0
                                          fi
                                          exit 0
                                       fi
                                     }
        "$checksum" "$file" | tee >(cut -d ' ' -f1 > $TMPF) | zenity --window-icon="info" --progress --title="$dialog" --text="File:\n<b> ${file##*/} </b>\n\n- Calculating $dialog. Please, wait..." --pulsate --auto-close
    action_cancel
    action_sum
    action_compare
done
exit