Skip to content

gabrielluizsf/file-encryptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Encryption and Decryption in Go

package main

import (
	"fmt"
	"github.com/gabrielluizsf/file-encryptor/encryptor"
	"github.com/gabrielluizsf/file-encryptor/input"
)

func main() {
	// Get user input
	userInput, err := input.User()
	if err != nil {
		fmt.Println(err)
		return
	}
	var (
		operation, secret     = userInput.Operation, userInput.Secret
		inputPath, outputPath = userInput.Path, userInput.OutputPath
	)
	// Create a new FileCrypto 'instance'
	fileCrypto, err := encryptor.NewFileCrypto(secret)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	// Perform the operation based on user input
	switch operation {
	case input.Encrypt:
		if err := fileCrypto.Encrypt(inputPath, outputPath); err != nil {
			fmt.Println("Error encrypting file:", err)
			return
		}
		fmt.Println("\nFile encrypted successfully")
	case input.Decrypt:
		if err := fileCrypto.Decrypt(inputPath, outputPath); err != nil {
			fmt.Println("Error decrypting file:", err)
			return
		}
		fmt.Println("\nFile decrypted successfully")
	}
}

About

Golang Package for File Encryption and Decryption

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages