Socket
Book a DemoInstallSign in
Socket

github.com/JeffDeCola/my-go-tools/cryptography-tools/md5-hash-file

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/JeffDeCola/my-go-tools/cryptography-tools/md5-hash-file

v0.0.0-20250420185612-543f759aff24
Source
Go
Version published
Created
Source

md5-hash-file TOOL

jeffdecola.com MIT License

Get an md5 hash (fingerprint) from an input file using the crypto/md5 standard package. I also added a flag to read in your .ssh/id_rsa.pub key to get your ssh fingerprint.

tl;dr

# INSTALL VIA GO
go install md5-hash-file.go

# GET MD5 FINGERPRINT ON FILE
md5-hash-file testfile.txt

# GET MD5 FINGERPRINT ON KEY FILE
md5-hash-file -ssh ~/.ssh/id_rsa.pub

Table of Contents

Documentation and Reference

OVERVIEW

In a nutshell, the guts of the code is,

plainTextBytes := []byte(plainText)

// HASH
md5HashByte := md5.Sum(plainTextBytes)

// CONVERT TO STRING
md5Hash := hex.EncodeToString(md5HashByte[:])

PREREQUISITES

You will need the following go packages,

go get -u -v github.com/sirupsen/logrus

RUN

To run.sh,

go run . testfile.txt
go run md5-hash-file.go testfile.txt
go run md5-hash-file.go testfile.txt -loglevel trace

If you run on testfile.txt your md5 hash shall be,

950dc9055bc2eb9b1f143e92d7bee6c4

You may also use the -ssh flag to read in a public ssh key file,

go run . -ssh ~/.ssh/id_rsa.pub
go run md5-hash-file.go -ssh ~/.ssh/id_rsa.pub
go run md5-hash-file.go -ssh ~/.ssh/id_rsa.pub -loglevel trace

Its nice because you can check you have the right fingerprint at github.com/settings/keys.

You can also run the unix command to check your md5,

ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub

TEST

To create _test files,

gotests -w -all md5-hash-file.go

To unit-tests.sh,

go test -cover ./... | tee test/test_coverage.txt
cat test/test_coverage.txt

INSTALL

Will place an executable in your go bin,

go install md5-hash-file.go

USAGE

md5-hash-file {-h|-v|-ssh} [FILENAME] -loglevel [level] 

-h

Help,

md5-hash-file -h

-v

Version,

md5-hash-file -v

-ssh

Check your public ssh file,

md5-hash-file -ssh ~/.ssh/id_rsa.pub

-loglevel string

Can use trace, info or error,

md5-hash-file -ssh ~/.ssh/id_rsa.pub -loglevel trace

FAQs

Package last updated on 20 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.