Skip to content

Commit

Permalink
feature: Ask for password confirmation on encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
fulldump committed Aug 5, 2022
1 parent 8858b06 commit 4bd5d5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ build:
release: clean
GOOS=linux GOARCH=arm64 go build $(FLAGS) -o bin/goz.linux.arm64 .
GOOS=linux GOARCH=amd64 go build $(FLAGS) -o bin/goz.linux.amd64 .
GOOS=windows GOARCH=arm64 go build $(FLAGS) -o bin/goz.win.arm64 .
GOOS=windows GOARCH=amd64 go build $(FLAGS) -o bin/goz.win.amd64 .
GOOS=windows GOARCH=arm64 go build $(FLAGS) -o bin/goz.win.arm64.exe .
GOOS=windows GOARCH=amd64 go build $(FLAGS) -o bin/goz.win.amd64.exe .
GOOS=darwin GOARCH=arm64 go build $(FLAGS) -o bin/goz.mac.arm64 .
GOOS=darwin GOARCH=amd64 go build $(FLAGS) -o bin/goz.mac.amd64 .
md5sum bin/* > bin/checksum
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type config struct {
}

// Source: https://go.dev/play/p/l-9IP1mrhA
func readPassword() []byte {
fmt.Fprint(os.Stderr, "Enter password: ")
func readPassword(prompt string) []byte {
fmt.Fprint(os.Stderr, prompt)
password, err := terminal.ReadPassword(0)
fmt.Fprintln(os.Stderr, "")
if err != nil {
Expand Down Expand Up @@ -61,7 +61,14 @@ func main() {

// todo: validate config

password := readPassword()
password := readPassword("Enter password: ")
if !c.Open {
confirm := readPassword("Confirm password: ")
if string(confirm) != string(password) {
fmt.Fprintln(os.Stderr, "Password does not match")
os.Exit(7)
}
}
key := GetMD5Hash(password)

files := []string{}
Expand Down

0 comments on commit 4bd5d5b

Please sign in to comment.