Wednesday, January 16, 2013

Generate SHA hash - OSX

I'll have to clean this post up later, but just to get this down.  Pulled the new Fedora 18 XFCE spin from the torrent and needed to verify it with the provided SHA256 hash.

At it's most basic:
computer:directory user$ shasum <filename>
<some_hash> <filename>
In the case below I needed a SHA256 hash so the -a arg was necessary:


computer:directory user$ shasum -a256 <filename>
<some_256_hash> <filename>


So, here is what I did - some content removed for brevity(...):

berlin:tmp bkarels$ cat Fedora-18-x86_64-Spins-CHECKSUM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
...
95a75c...29dd6e *Fedora-18-x86_64-Live-XFCE.iso
berlin:tmp bkarels$ shasum -a256 Fedora-18-x86_64-Live-XFCE.iso
95a75c...29dd6e  Fedora-18-x86_64-Live-XFCE.iso
Checking the hash against a provided list was not as clear from the man pages.  In brief you need to use the output of a shasum as input to shasum -c.  Here you need only find 'OK' vs. relying on your human ability to visually compare hashes on a terminal.

Basic:
computer:directory user$ shasum -a 256 <filename> | shasum -c <CHECKSUM_FILE>
blah blah blah output: OK
Example:
berlin:tmp bkarels$ shasum -a 256 Fedora-18-x86_64-Live-XFCE.iso | shasum -c Fedora-18-x86_64-Spins-CHECKSUM
...
shasum: Fedora-18-x86_64-Live-Scientific-KDE.iso: No such file or directory
Fedora-18-x86_64-Live-Scientific-KDE.iso: FAILED open or read
shasum: Fedora-18-x86_64-Live-Security.iso: No such file or directory
Fedora-18-x86_64-Live-Security.iso: FAILED open or read
shasum: Fedora-18-x86_64-Live-SoaS.iso: No such file or directory
Fedora-18-x86_64-Live-SoaS.iso: FAILED open or read
Fedora-18-x86_64-Live-XFCE.iso: OKshasum: WARNING: 7 of 8 listed files could not be read
Fin.

NOTE: For clarity, here is the entire contents of the example file Fedora-18-x86_64-Spins-CHECKSUM:


berlin:tmp bkarels$ cat Fedora-18-x86_64-Spins-CHECKSUM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
3684ae2814c7e54b4f66f0411a385846533e40f107d7fff4e331c2f547951ec2 *Fedora-18-x86_64-Live-Design-suite.iso
b11da64d527e333e2160cbf5fde49f89205f932d48fa7c01690232fc1b0cacfa *Fedora-18-x86_64-Live-Electronic-Lab.iso
ea34f626488623a1f84b2041df9c65468357bfdb878f034392da16f6c9d05264 *Fedora-18-x86_64-Live-LXDE.iso
8700aa64a6485e338b3d9aa419ecadc0c87884c77203a35c6e1847147a4dca06 *Fedora-18-x86_64-Live-Robotics.iso
3bb90d115daf6f0d2279cd5a669fb265c090cb6e88125424ae960a980f9ba50d *Fedora-18-x86_64-Live-Scientific-KDE.iso
7802a1c024f9471fba90724f53c0d95045acd76c3c4346b467cb53f5608248a9 *Fedora-18-x86_64-Live-Security.iso
736e8dd36de4207fe899648299abb6b3220fd1d1bcb48b8bf712d01d2ec02bf5 *Fedora-18-x86_64-Live-SoaS.iso
95a75c334ce82b33f1a5d81eab196600e40c7933fd5f7bfa8e6ed9534529dd6e *Fedora-18-x86_64-Live-XFCE.iso
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iQIcBAEBCAAGBQJQ8FZnAAoJEP8BElzefzi9BdUQALd1dlX39NVq/GWuoR7iCrxo
+ZS5gFzp5ObdPp2+MFdKszMEI7HQnkv5Xvj7qTrUS41LwrLSAX7BN5wiuzYbD0wv
f10U7K907inViXWUbANCx/fqVDLXtC/lkRYMh0JEOyRP6VYCOjcTzby+pxfOhG3u
naAtUApx/WbydwOheyT1GJCV8e15/oXqYxDoJmQuAX7AliDyysVdtcsgDP9GEiJ+
jApOywZHdxVYzUJQlXkoYEAn9LzeOh69MEL8wP30GHGI4GBo0CMUouhXlvcnoNyj
Ov9Px/8xFSSQ6vs7rapayyaue4vCxa13Y79KKQzh+/f0G2KXgInW59Y70Q0lYkLS
SCYwNUxACSlguetDfzqTtXTAFbYUcHTcc6YLuCQGRUZbDNev/dq5pnIMLSQiDnKq
YXQd1a8qH0ZpRQCMHhRwYq6satKz1ui0PgRpAn4ScPdye8Fda9+tC5VI07SDEduX
lDvzgNgOIWA3dMgSPkcaW/jcanAB3ubgPxiyAitU12TzEPwE8RuMFlYhoIczr5pu
g1aQrw/kOng6OJGjlJWd5Sb3Qabsm3OW3hfJ7wER9TRWdDT2zwo3A+j6hYsE5og+
oLbVJhQFyqpIr9o5rhtoU3bVIyOqjl5WY+4PlTrQ+1gt1qjrY9Z0tzoSGk3ESaMi
txw7WyBRjomA/D+4jzMR
=/hTc
-----END PGP SIGNATURE-----