You are not logged in.

#1 2015-07-26 15:59:16

genEric
Member
From: Sweden
Registered: 2013-09-26
Posts: 38

chksum - script to verifying checksums

chksum

This is a script I use almost on daily basis. I use it for everything I download which has a checksum on the side to verify it with. I first made it in OS X, but it's been updated a while ago to work on Linux/*BSD as well (eg with the GNU-Utils). It's nothig fancy or so, just a simple “helper”. (I'm sure the script could be written more optimized, but hey … it works.) smile

Link: chksum

Example:

$ chksum md5 d41d8cd98f00b204e9800998ecf8427e foo.bar
foo.bar:        ... OK

$ chksum md5 d41d8cd98f00b204e9800998ecf8427f foo.bar
foo.bar:        ... FAILED

chksum: WARNING: The checksum (d41d8cd98f00b204e9800998ecf8427f) did NOT match

- - -

2 xtras (somewhat related)

Coming from OS X, I (sometimes) miss `md5` and `shasum`. So, in case anyone else needs them for the transition or to use as a layer to make (osx) scripts compatible. Here are 2 (very) simple wrappers. There are no advance checking or anything, just 2-3 options from each “translated”. smile I once found a MD5 I compiled, but it wasn't the same thing.

MD5
File: md5
ReadMe: md5.md

What I miss in `md5sum` is -s and -q options.
Examples:

# -s = string (text)
$ md5 -s "I'm a text string"
MD5 ("I'm a text string") = 9fb4b4561f538606cd87bf69a7c67c6e

# -q = silent. Only the checksum. Great for scripting. 
$ md5 -q fooBar.txt
d41d8cd98f00b204e9800998ecf8427e

shasum
File: shasum
ReadMe: shasum.md

`shasum` Includes all shaNNNsum...
Examples:

# default = sha1
$ shasum fooBar.txt 
da39a3ee5e6b4b0d3255bfef95601890afd80709  fooBar.txt

# -a = algoritm
shasum -a 256 fooBar.txt
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  fooBar.txt

Perhaps not the most useful ones, but they've helped me in my transition. And sometimes the “muscle memory” kicks in (since I stlll use OS X on the side) and I type them accidently. And not that I not use the GNU-utils programs, they servre more as complliments/addons (to me).

- - -

Hope you find them useful.

/Eric

Last edited by genEric (2015-08-08 08:36:52)


[genEric@…] ~$

Offline

#2 2015-07-26 16:42:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,456
Website

Re: chksum - script to verifying checksums

I don't know why you miss these tools, they certainly exist in linux:

$ pkgfile md5sum
core/coreutils

$ echo -n "I'm a text string" | md5sum                                                                                                                                                
9fb4b4561f538606cd87bf69a7c67c6e  -

$ ls /usr/bin/sha*
/usr/bin/sha1pass  /usr/bin/sha1sum  /usr/bin/sha224sum  /usr/bin/sha256sum  /usr/bin/sha384sum  /usr/bin/sha512sum

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2015-07-26 23:02:12

genEric
Member
From: Sweden
Registered: 2013-09-26
Posts: 38

Re: chksum - script to verifying checksums

Trilby wrote:

I don't know why you miss these tools, they certainly exist in linux:
// ... //

Ah, sorry. It wasn't what I (really) meant. I guess it's more the programs/syntax itself. Of course I can perform simular things with the GNU-utils software. The wrappers are more a way to be able to use them in another way. And of course, as compat layers if/when I need them. But those were just xtras. It was `chksum` I wanted to share.


[genEric@…] ~$

Offline

#4 2015-08-25 10:13:14

X-dark
Member
From: France
Registered: 2009-10-25
Posts: 142
Website

Re: chksum - script to verifying checksums

genEric wrote:
chksum

Example:

$ chksum md5 d41d8cd98f00b204e9800998ecf8427e foo.bar
foo.bar:        ... OK

$ chksum md5 d41d8cd98f00b204e9800998ecf8427f foo.bar
foo.bar:        ... FAILED

chksum: WARNING: The checksum (d41d8cd98f00b204e9800998ecf8427f) did NOT match

Sorry but what is the difference with just doing this:

$ echo "d41d8cd98f00b204e9800998ecf8427e foo.bar" | md5sum -c
foo.bar: OK

$ echo "d41d8cd98f00b204e9800998ecf8427f foo.bar" | md5sum -c
foo.bar: FAILED
md5sum: WARNING: 1 computed checksum did NOT match

Cedric Girard

Offline

Board footer

Powered by FluxBB