sha256 Match Script [SOLVED]
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
sha256 Match Script [SOLVED]
Alright you sudo gurus, I am really tired of copy and pasting sha256 checksums into a text document and matching them up. I was wondering if anybody has a script that could be run to hold the first input and match it to the second input with and output of either yes or no. It may be easy, but I'm not on that level of scripting yet. Thanks in advance.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
- JoeFootball
- Level 13
- Posts: 4673
- Joined: Tue Nov 24, 2009 1:52 pm
- Location: /home/usa/mn/minneapolis/joe
Re: sha256 Match Script
If you're using any Linux released within the past five years or so, have both the ISO and sha256sum.txt files in the same directory, and execute within that directory ...wvufantim wrote: ... and output of either yes or no.
sha256sum --ignore-missing -c sha256sum.txt
... where it will do the comparison for you, returning
OK
or Failed
.Re: sha256 Match Script
If the want though is to not create said sha256sum.txt file at all this can be easily done using e.g. bash' process substitution using that same by Joe provided method. For example,
~/bin/sha256chk (executable)
to be used as e.g.
Feel of course free to swap $1 and $2 is that's the order you want. If you insist on the yes/no thing you'd use the same idea to have e.g.
~/bin/sha256chk (executable)
Code: Select all
#!/bin/bash
sha256sum -c <(echo $2 $1)
Code: Select all
$ sha256chk foo e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
foo: OK
Code: Select all
#!/bin/bash
sha256sum --status -c <(echo $2 $1) && echo yes || echo no
Re: sha256 Match Script
I don't understand a bit.
But maybe such an example will also be good.
This is only part code of script for download Firefox portable.
But maybe such an example will also be good.
Code: Select all
ERROR()
{
echo "$@" ; exit 1
}
# Download sum
SUM=$(curl -v --silent https://ftp.mozilla.org/pub/firefox/releases/${VERSION_FIREFOX}/SHA256SUMS --stderr - | grep "linux-i686/${LANGUAGE}/firefox-${VERSION_FIREFOX}.tar.bz2" \
| awk '{print $1}')
echo " "
echo "--> Checking the checksum sha256sum"
echo "$SUM firefox-${VERSION_FIREFOX}.tar.bz2" | sha256sum --check
[ $? == 0 ] || ERROR "--> Downloaded file is broken or sha256sum not exist!"
echo " "
Re: sha256 Match Script
Mmm. Right. As per 1000, you don't in fact even need the process substitution at all; without argument
in which
sha256sum -c
reads the sum file from stdin. That's to say then that sha256chk
can even just beCode: Select all
#!/bin/sh
echo $2 $1 | sha256sum -c
#!/bin/sh
rather than #!/bin/bash
is of note.Re: sha256 Match Script
Thanks for the replies!!!
Maybe just a script that compares one number on the first input to the second input to see if it is true or false?
Maybe just a script that compares one number on the first input to the second input to see if it is true or false?
Re: sha256 Match Script
The "input" is not well-defined and a number is not true or false (but e.g. 1, or 2, or...).
I.e., no idea what you're saying. If the above does not do what you need, be explicit as to why not and as to what you want to type and what you want returned.
Re: sha256 Match Script
Do you object to the copy and paste part or the manual checking of one number to the other?
There's an app for this you know:
Code: Select all
sudo apt install gtkhash
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Re: sha256 Match Script
Example:
Okay, a script in which you run it:
./compare
echo: What is your number?
Input: 81f375163731864e281b5a704466fff46b74f74d4d1aab8eb65efc1a66709064
echo: What is your compare number?
Input: 81f375163731864e281b5a704466fff46b74f74d4d1aab8eb65efc1a66709064
Output is:
Your numbers are the same! or Your numbers DO NOT MATCH!
Re: sha256 Match Script
That works!!!! I like the check marks that indicate that they match. Thanks so much.altair4 wrote: ⤴Sun Nov 07, 2021 8:35 amDo you object to the copy and paste part or the manual checking of one number to the other?
There's an app for this you know:Looks like this by default:Code: Select all
sudo apt install gtkhash
gtkhash.png
You still have to copy and paste into the "Check" box if you want a compare.