πΎ Archived View for source.community βΊ jeffdecola βΊ my-go-tools βΊ tree βΊ develop βΊ cryptography-toolβ¦ captured on 2024-05-10 at 11:22:17. Gemini links have been rewritten to link to archived content
β¬ οΈ Previous capture (2024-02-05)
-=-=-=-=-=-=-
. ,-. ,-. . . ,-. ,-. ,-. ,-. ,-. ,-,-. ,-,-. . . ,-. . |- . . `-. | | | | | | |-' | | | | | | | | | | | | | | | | | `-' `-' `-^ ' `-' `-' :: `-' `-' ' ' ' ' ' ' `-^ ' ' ' `' `-| /| `-'
git clone https://source.community/jeffdecola/my-go-tools.git
`decryptfile` _is a useful tool for decryptfile a file with AES-256 GCM (a 32-byte hash key) using the `crypto/aes` package.
Works with encryptfile[1]._
Table of Contents,
- OVERVIEW[1]
- STEP 1 - CREATE A HASH KEY[1]
- STEP 2 - DECRYPT 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]
2: STEP 2 - DECRYPT FILE WITH 32 BYTE HASH KEY
Documentation and references,
- Use my other tool
encryptfile[1] to encrypt * Refer to my aes-256-gcm[2] example in `my-go-examples` repo on how I did the decryption.
- This repos
github webpage[1] _built with concourse[2]_
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.
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.
hasher := md5.New() hasher.Write([]byte(paraphrase)) hash := hex.EncodeToString(hasher.Sum(nil))
The encryption was done using AES-256 GCM from my example aes-256-gcm[1] Refer to that example for a complete description.
This illustration may help,
IMAGE - decryptfile - IMAGE[1]
1: IMAGE - decryptfile - IMAGE
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 decryptfile.go[1] from the command line,
go run . -i encrypted.txt -o output.txt go run decryptfile.go -i encrypted.txt -o output.txt go run decryptfile.go -i encrypted.txt -o output.txt -debug go run decryptfile.go -i encrypted.txt -o output.txt -paraphrasefile paraphrase.txt go run decryptfile.go -i encrypted.txt -o output.txt -paraphrasefile ~/.ssh/id_rsa
Use the paraphrase `test`.
The following steps are located in unit-tests.sh[1].
To create `_test` files,
gotests -w -all decryptfile.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 decryptfile.go
decryptfile {-h|-v|-debug} -i [input file] -o [output file] -paraphrasefile [file]
Help,
decryptfile -h
Version,
decryptfile -v
Use a specific input file and output file`,
decryptfile -i encrypted.txt -o output.txt
Use a file as the paraphrase,
decryptfile -i encrypted.txt -o output.txt -paraphrasefile ~/.ssh/id_rsa
decryptfile -i encrypted.txt -o output.txt -debug
Β· Β· Β·
Β© 2024 source.community