πŸ’Ύ Archived View for source.community β€Ί jeffdecola β€Ί my-go-tools β€Ί tree β€Ί develop β€Ί cryptography-tool… captured on 2023-07-10 at 13:41:23. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

➑️ Next capture (2024-02-05)

🚧 View Differences

-=-=-=-=-=-=-

                                                         .
,-. ,-. . . ,-. ,-. ,-.    ,-. ,-. ,-,-. ,-,-. . . ,-. . |- . .
`-. | | | | |   |   |-'    |   | | | | | | | | | | | | | |  | |
`-' `-' `-^ '   `-' `-' :: `-' `-' ' ' ' ' ' ' `-^ ' ' ' `' `-|
                                                             /|
                                                            `-'

Profile for jeffdecola

jeffdecola / my-go-tools

git clone https://source.community/jeffdecola/my-go-tools.git

Branches

Log

/cryptography-tools/sha256-hash-file/ (develop)

↑ /cryptography-tools

tree

πŸ“ test/

πŸ“„ README.md

πŸ“„ go.mod

πŸ“„ go.sum

πŸ“„ run.sh

πŸ“„ sha256-hash-file.go

πŸ“„ sha256-hash-file_test.go

πŸ“„ testfile.txt

sha256-hash-file tool

`sha256-hash-file` _is a useful tool for getting an sha256 hash (fingerprint) from an input file using the standard `crypto/sha256` package.

I also added a flag to read in your .ssh/id_rsa.pub key to get your ssh sha256 fingerprint._

Table of Contents,

- OVERVIEW[1]

1: OVERVIEW

- PREREQUISITES[1]

- RUN[2]

- TEST[3]

- INSTALL[4]

- USAGE[5]

- -h[6]

- -v[7]

- -ssh[8]

- -debug[9]

1: PREREQUISITES

2: RUN

3: TEST

4: INSTALL

5: USAGE

6: -h

7: -v

8: -ssh

9: -debug

Documentation and references,

- Refer to

sha256-hash-from-file[1] example in `my-go-examples` * This repos github webpage[2] _built with concourse[3]_

1: sha256-hash-from-file

2: github webpage

3: concourse

OVERVIEW

In a nutshell, the guts of the code is,

plainTextBytes := []byte(plainText)

// HASH
sha256HashByte := sha256.Sum256(plainTextBytes)

// CONVERT TO STRING
sha256Hash := base64.RawStdEncoding.EncodeToString(sha256HashByte[:])

PREREQUISITES

I used the following language,

- go[1]

1: go

You will need the following go packages,

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

RUN

The following steps are located in run.sh[1].

1: run.sh

To run sha256-hash-file.go[1] from the command line,

1: sha256-hash-file.go

go run . testfile.txt
go run sha256-hash-file.go testfile.txt
go run sha256-hash-file.go -debug testfile.txt

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

r2pN5Sjq43jggvxvW34cT6s662//HfyemRss38ZA+vk

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

go run . -ssh ~/.ssh/id_rsa.pub
go run sha256-hash-file.go -ssh ~/.ssh/id_rsa.pub
go run sha256-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].

1: github.com/settings/keys

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

 ssh-keygen -lf ~/.ssh/id_rsa.pub

TEST

The following steps are located in unit-tests.sh[1].

1: unit-tests.sh

To create `_test` files,

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

To unit test the code,

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

INSTALL

Will place an executable in your go bin,

go install sha256-hash-file.go

USAGE

sha256-hash-file {-h|-v|-debug|-ssh} [FILENAME]

-h

Help,

sha256-hash-file -h

-v

Version,

sha256-hash-file -v

-ssh

Check your public ssh file,

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

-debug

sha256-hash-file -debug testfile.txt

Β· Β· Β·

🏑 Home

FAQs

Privacy Policy

Terms & Conditions

Official Gemlog

info@source.community

Β© 2023 source.community