encdec

module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2024 License: Apache-2.0

README

encdec

CLI and packages to encrypt / decrypt files.

CLI usage

Install
go install github.com/cassioconti/encdec/cmd/encdec@latest
Consume
SECRET=abcdefghijklmnopqrstuvwxyz123456

# Encrypt - will output the encrypted file to test/data/my-test-file.json.enc
encdec encrypt test/data/my-test-file.json $SECRET

# Decrypt - will output the decrypted file to test/data/my-test-file.json
encdec decrypt test/data/my-test-file.json.enc $SECRET

Package usage

Import
go get -u github.com/cassioconti/encdec/pkg/encdec
Consume
import "github.com/cassioconti/encdec/pkg/encdec"

func myFunc() {
    secret := "abcdefghijklmnopqrstuvwxyz123456"
	contentOriginal := []byte("This is an example of the content. Content can be any []byte.")
	encDec := encdec.NewEncoderDecoder()
	contentEncrypted, err := encDec.Encrypt(contentOriginal, secret)
	if err != nil {
		// handle error
	}

	contentDecrypted, err := encDec.Decrypt(contentEncrypted, secret)
	if err != nil {
		// handle error
	}

	fmt.Printf("%s\n", contentDecrypted)
}

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL