πΎ Archived View for source.community βΊ jeffdecola βΊ my-go-tools βΊ tree βΊ develop βΊ cryptography-toolβ¦ captured on 2023-09-08 at 16:21:59. Gemini links have been rewritten to link to archived content
β¬ οΈ Previous capture (2023-07-10)
β‘οΈ Next capture (2024-02-05)
-=-=-=-=-=-=-
. ,-. ,-. . . ,-. ,-. ,-. ,-. ,-. ,-,-. ,-,-. . . ,-. . |- . . `-. | | | | | | |-' | | | | | | | | | | | | | | | | | `-' `-' `-^ ' `-' `-' :: `-' `-' ' ' ' ' ' ' `-^ ' ' ' `' `-| /| `-'
git clone https://source.community/jeffdecola/my-go-tools.git
`md5-hash-file` _is a useful tool for getting an md5 hash (fingerprint) from an input file using the standard `crypto/md5` package.
I also added a flag to read in your .ssh/id_rsa.pub key to get your ssh md5 fingerprint._
Table of Contents,
- OVERVIEW[1]
- PREREQUISITES[1]
- RUN[2]
- TEST[3]
- INSTALL[4]
- USAGE[5]
- -h[6]
- -v[7]
- -ssh[8]
- -debug[9]
Documentation and references,
- Refer to
md5-hash-from-file[1] example in `my-go-examples` * This repos github webpage[2] _built with concourse[3]_
In a nutshell, the guts of the code is,
plainTextBytes := []byte(plainText) // HASH md5HashByte := md5.Sum(plainTextBytes) // CONVERT TO STRING md5Hash := hex.EncodeToString(md5HashByte[:])
I used the following language,
- go[1]
You will need the following go packages,
go get -u -v github.com/sirupsen/logrus
The following steps are located in run.sh[1].
To run md5-hash-file.go[1] from the command line,
go run . testfile.txt go run md5-hash-file.go testfile.txt go run md5-hash-file.go -debug testfile.txt
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 -debug ~/.ssh/id_rsa.pub
Its nice because you can check you have the right fingerprint at github.com/settings/keys[1].
You can also run the unix command to check your md5,
ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub
The following steps are located in unit-tests.sh[1].
To create `_test` files,
gotests -w -all md5-hash-file.go
To unit test the code,
go test -cover ./... | tee test/test_coverage.txt cat test/test_coverage.txt
Will place an executable in your go bin,
go install md5-hash-file.go
md5-hash-file {-h|-v|-debug|-ssh} [FILENAME]
Help,
md5-hash-file -h
Version,
md5-hash-file -v
Check your public ssh file,
md5-hash-file -ssh ~/.ssh/id_rsa.pub
md5-hash-file -debug testfile.txt
Β· Β· Β·
Β© 2023 source.community