Bitcoin Forum
May 02, 2024, 12:21:21 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Guide] How to simply compute and check hash functions via command-line tools  (Read 154 times)
10_sjdovn_10 (OP)
Member
**
Offline Offline

Activity: 100
Merit: 30

Stay humble, be cool, make world better place.


View Profile
October 12, 2021, 09:14:34 AM
Last edit: October 13, 2021, 07:11:34 AM by 10_sjdovn_10
Merited by Welsh (6), DdmrDdmr (6), NotATether (4)
 #1


Hi people, did you ever check  md5, sha-256, sha-512 from a file or generate it with the help of (Linux or Mac os) command-line tools?

This quick tutorial help you compute and check cryptographic hash functions and message digest ,with the help of command-line tools in Linux or Mac os
You probably want to make sure about data integrity of your downloaded software(wallet or a file)

-> First of all search and open an application called terminal on your Linux/Mac Pc.


1 To print 512-bit checksum to standard-output: (if no /path/to/myFile specified or  - used it reads the file from standard-input)
Quote
$ sha512sum /path/to/myFile
or
$ cat /path/to/myFile | sha512sum

-> It is possible to pass many files you want:
Quote
$ sha512sum file1 file2 file3



2 If you want to check a sha-512 from a file, you need to have second file which hold hash string of that file in the same directory where the original file is.
you shuld use:        -c , --check
Quote
$ sha512sum -c second_file

output   ---->  myFile: OK       (if it matches) ✔︎        
            ---->  myFile: FAILED  (if not matches) ✗

-> Using [--status] prints nothing but, 0 status code if matches, 1 status code if not matches.


3 Structure of second_file :
Quote
c94513342f28407c5105427c1f587c6f6b10219767930eca48bb4315461201c62207e510b19e6b4 900a8f095650e3275f24894ba52f85b740b1ede2d0d6c9500  myFile
da8b193faffed956886ad26377d11d9a1801ace2f8907bf2e95efb8b869d1803fd4f017407cec20 a45dea94555b172e482ebf7cf24642f81f20779511f986b2c  myFile2
...

-> Note that two space between hash string and myFile.
-> This will help if you copy/paste a hash string and send it to standard-input of sha512sum:
Quote
$ echo "da8b193faffed956886ad26377d11d9a1801ace2f8907bf2e95efb8b869d1803fd4f017407cec20 a45dea94555b172e482ebf7cf24642f81f20779511f986b2c   myFile" | sha512sum -c

-> You can also use 256-bit or sha-1 or md5 : just write $ sha1sum | md5sum | sha256sum instead.
-> On Mac os you should use shasum program but use -a 512 or 256
-> If you are confuse about directory of a file, simply drag and drop the file into terminal.



Do you know some command-line tools related to cryptography or Bitcoin ?

I would appreciate to professional users for their feedback on this tutorial
-Mike
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714609281
Hero Member
*
Offline Offline

Posts: 1714609281

View Profile Personal Message (Offline)

Ignore
1714609281
Reply with quote  #2

1714609281
Report to moderator
1714609281
Hero Member
*
Offline Offline

Posts: 1714609281

View Profile Personal Message (Offline)

Ignore
1714609281
Reply with quote  #2

1714609281
Report to moderator
Cookdata
Hero Member
*****
Offline Offline

Activity: 938
Merit: 876


Not Your Keys, Not Your Bitcoin


View Profile
October 12, 2021, 10:28:38 PM
 #2

I'd like to see how this works in Windows and how to check the integrity of files, but the above also appears to be very difficult to the eye without an illustration image, but perhaps Marc users understand what the OP is demonstrating.
Bitcoin uses Sha-256, but is this the same for files and documents? I see Sha-512 as well from your first paragraph.

nakamura12
Hero Member
*****
Offline Offline

Activity: 2254
Merit: 669


Bitcoin Casino Est. 2013


View Profile
October 13, 2021, 03:21:43 AM
 #3

I'd like to see how this works in Windows and how to check the integrity of files, but the above also appears to be very difficult to the eye without an illustration image, but perhaps Marc users understand what the OP is demonstrating.
Bitcoin uses Sha-256, but is this the same for files and documents? I see Sha-512 as well from your first paragraph.
As far as I'm concern, the location of the file is different from mac/linux user so you won't find file you are looking for if you use same path it could be found. It would be good if op also share on how to do it on windows too as not all are using mac/linux. You are right that mac users will know how to do it but not all if you are not a techy guy.

███▄▀██▄▄
░░▄████▄▀████ ▄▄▄
░░████▄▄▄▄░░█▀▀
███ ██████▄▄▀█▌
░▄░░███▀████
░▐█░░███░██▄▄
░░▄▀░████▄▄▄▀█
░█░▄███▀████ ▐█
▀▄▄███▀▄██▄
░░▄██▌░░██▀
░▐█▀████ ▀██
░░█▌██████ ▀▀██▄
░░▀███
▄▄██▀▄███
▄▄▄████▀▄████▄░░
▀▀█░░▄▄▄▄████░░
▐█▀▄▄█████████
████▀███░░▄░
▄▄██░███░░█▌░
█▀▄▄▄████░▀▄░░
█▌████▀███▄░█░
▄██▄▀███▄▄▀
▀██░░▐██▄░░
██▀████▀█▌░
▄██▀▀██████▐█░░
███▀░░
nc50lc
Legendary
*
Offline Offline

Activity: 2394
Merit: 5578


Self-proclaimed Genius


View Profile
October 13, 2021, 08:24:11 AM
Merited by Welsh (6), DdmrDdmr (6), pooya87 (2), Pmalek (1)
 #4

I'd like to see how this works in Windows and how to check the integrity of files, -snip-
There's Windows "PowerShell" and you can use the "Get-FileHash" utility: Instructions/Source

Example: Let's get the SHA256 hash of Bitcoin Core v22.0 installer in my "Backup & Installers" folder; open Windows PowerShell then type:
Code:
get-filehash "E:\Backup & Installers\bitcoin-22.0-win64-setup.exe" -algorithm SHA256 | format-list
Enclose the path with quotes (like I did) if it has spaces or other illegal characters.

Results will be:
Code:
Algorithm : SHA256
Hash      : 9169989D649937C0F9EBCCD3AB088501328AA319FE9E91FC7EA8E8CF0FCCCEDE
Path      : E:\Backup & Installers\bitcoin-22.0-win64-setup.exe

Which matched with the hash of 64-bit Win setup file in SHA256SUMS file from https://bitcoincore.org/bin/bitcoin-core-22.0/:
Code:
9169989d649937c0f9ebccd3ab088501328aa319fe9e91fc7ea8e8cf0fcccede  bitcoin-22.0-win64-setup.exe

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
NeuroticFish
Legendary
*
Offline Offline

Activity: 3654
Merit: 6371


Looking for campaign manager? Contact icopress!


View Profile
October 13, 2021, 09:18:14 AM
Merited by Welsh (4), DdmrDdmr (4), Pmalek (1)
 #5

I'd like to see how this works in Windows and how to check the integrity of files, -snip-
There's Windows "PowerShell" and you can use the "Get-FileHash" utility

Windows has also the option to do this without PowerShell, with certutil, which seems to be part of all recent windows versions (Win 7+)

Code:
certutil -hashfile bitcoin-22.0-win64.zip SHA256

with the result:

Code:
SHA256 hash of bitcoin-22.0-win64.zip:
9485e4b52ed6cebfe474ab4d7d0c1be6d0bb879ba7246a8239326b2230a77eb1
CertUtil: -hashfile command completed successfully.

It also works for MD5 or SHA512 too, you have to just change the parameter accordingly.

Code:
Hash algorithms: MD2 MD4 MD5 SHA1 SHA256 SHA384 SHA512

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6718


bitcoincleanup.com / bitmixlist.org


View Profile WWW
October 13, 2021, 03:30:14 PM
 #6

I'd like to see how this works in Windows and how to check the integrity of files, but the above also appears to be very difficult to the eye without an illustration image, but perhaps Marc users understand what the OP is demonstrating.

You can get md5/sha256/sha512sum programs on Windows by installing the MinGW tool suite (which you get for free with MSYS2 shell https://www.msys2.org/)

The tools probably won't hash bitcoin structs such as transactions, blocks correctly as-is, though, because they first have to be decoded from hex.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
donaldlloyd
Newbie
*
Offline Offline

Activity: 24
Merit: 0


View Profile
October 28, 2021, 05:49:26 AM
 #7

SHA (Secure Hash Algorithm) is a set of cryptographic hash functions. You can compute hash via the SHA function in Linux.
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6718


bitcoincleanup.com / bitmixlist.org


View Profile WWW
October 28, 2021, 07:09:04 AM
 #8

You can compute hash via the SHA function in Linux.

There is no "SHA function" shipped with Linux per se, you have to use one of the GNU "*sum" programs if you want to get the hash of all the bytes in a file or buffer. The existence of these commands is not guaranteed as some distros/variants of Linux don't package coreutils.

For input interpretation in hexadecimal, you need to call one of OpenSSL's functions in C code (requires you have OpenSSL development headers installed on your system - the bare OpenSSL library is NOT enough) after manually decoding the hex yourself.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!