πŸ’Ύ Archived View for source.community β€Ί jeffdecola β€Ί my-go-tools β€Ί tree β€Ί develop β€Ί cryptography-tool… captured on 2024-02-05 at 10:00:24. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-07-10)

🚧 View Differences

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

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

Profile for jeffdecola

jeffdecola / my-go-tools

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

Branches

Log

/cryptography-tools/encryptfile/ (develop)

↑ /cryptography-tools

tree

πŸ“ test/

πŸ“„ README.md

πŸ“„ encrypted_test.txt

πŸ“„ encryptfile.go

πŸ“„ encryptfile_test.go

πŸ“„ go.mod

πŸ“„ go.sum

πŸ“„ input.txt

πŸ“„ paraphrase.txt

πŸ“„ run.sh

encryptfile tool

`encryptfile` _is a useful tool for encryptfile a file with AES-256 GCM (a 32-byte hash key) using the `crypto/aes` package.

Works with decryptfile[1]._

1: decryptfile

Table of Contents,

- OVERVIEW[1]

1: OVERVIEW

- STEP 1 - CREATE A HASH KEY[1]

- STEP 2 - ENCRYPT FILE WITH 32 BYTE HASH KEY[2]

- PREREQUISITES[3]

- RUN[4]

- TEST[5]

- INSTALL[6]

- USAGE[7]

- -h[8]

- -v[9]

- -i string, -o string[10]

- -paraphrasefile string[11]

- -debug[12]

1: STEP 1 - CREATE A HASH KEY

2: STEP 2 - ENCRYPT FILE WITH 32 BYTE HASH KEY

3: PREREQUISITES

4: RUN

5: TEST

6: INSTALL

7: USAGE

8: -h

9: -v

10: -i string, -o string

11: -paraphrasefile string

12: -debug

Documentation and references,

- Use my other tool

decryptfile[1] to decrypt * Refer to my aes-256-gcm[2] example in `my-go-examples` repo on how I did the decryption.

1: decryptfile

2: aes-256-gcm

- This repos

github webpage[1] _built with concourse[2]_

1: github webpage

2: concourse

OVERVIEW

The Advanced Encryption Standard, or AES, is a symmetric block cipher chosen by the U.S. government to protect classified information and is implemented in software and hardware throughout the world to encrypt sensitive data.

We're going to use AES-256 GCM encryption from the standard go crypto/aes[1] package.

1: crypto/aes

STEP 1 - CREATE A HASH KEY

First you need a 32 byte key (AES-256). Instead of typing a 32 character in, lets make it simple by turning a simple paraphrase into a key.

We will use the standard go crypto/md5[1] package.

1: crypto/md5

hasher := md5.New()
hasher.Write([]byte(paraphrase))
hash := hex.EncodeToString(hasher.Sum(nil))

STEP 2 - ENCRYPT FILE WITH 32 BYTE HASH KEY

The encryption was done using AES-256 GCM from my example aes-256-gcm[1].

1: aes-256-gcm

Refer to that example for a complete description.

This illustration may help,

IMAGE - encryptfile - IMAGE[1]

1: IMAGE - encryptfile - IMAGE

PREREQUISITES

I used the following language,

- go[1]

1: go

You will need the following go packages,

go install -v github.com/sirupsen/logrus

RUN

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

1: run.sh

To run encryptfile.go[1] from the command line,

1: encryptfile.go

go run . -i input.txt -o encrypted.txt
go run encryptfile.go -i input.txt -o encrypted.txt
go run encryptfile.go -i input.txt -o encrypted.txt -debug
go run encryptfile.go -i input.txt -o encrypted.txt -paraphrasefile paraphrase.txt
go run encryptfile.go -i input.txt -o encrypted.txt -paraphrasefile ~/.ssh/id_rsa

Use the paraphrase `test`.

TEST

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

1: unit-tests.sh

To create `_test` files,

gotests -w -all encryptfile.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 encryptfile.go

USAGE

encryptfile {-h|-v|-debug} -i [input file] -o [output file] -paraphrasefile [file]

-h

Help,

encryptfile -h

-v

Version,

encryptfile -v

-i string, -o string

Use a specific input file and output file,

encryptfile -i input.txt -o encrypted.txt

-paraphrasefile string

Use a file as the paraphrase,

encryptfile -i input.txt -o encrypted.txt -paraphrasefile ~/.ssh/id_rsa

-debug

encryptfile -i input.txt -o encrypted.txt -debug

Β· Β· Β·

🏑 Home

FAQs

Privacy Policy

Terms & Conditions

Official Gemlog

info@source.community

Β© 2024 source.community