Skip to content

Commit

Permalink
added mac+linux+windows support AND global build setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinandan-Khurana committed Mar 6, 2024
1 parent 72a0bf1 commit 0efcd7a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
Binary file added EncryptGuard
Binary file not shown.
22 changes: 9 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import (
"bytes"
"fmt"
"os"
"runtime"
"syscall"

"github.com/Abhinandan-Khurana/EncryptGuard/filecrypt"
"github.com/fatih/color"
"golang.org/x/sys/windows"
"golang.org/x/term"
)

func main() {
Expand Down Expand Up @@ -41,9 +37,9 @@ func printHelp() {
yellow := color.New(color.FgYellow).Add(color.Bold)
fmt.Println("")
magenta.Println(`
____ _ _ ____ ____ _ _ ___ ___ ____ _ _ ____ ____ ___
|___ |\ | | |__/ \_/ |__] | | __ | | |__| |__/ | \
|___ | \| |___ | \ | | | |__] |__| | | | \ |__/
____ _ _ ____ ____ _ _ ___ ___ ____ _ _ ____ ____ ___
|___ |\ | | |__/ \_/ |__] | | __ | | |__| |__/ | \
|___ | \| |___ | \ | | | |__] |__| | | | \ |__/
`)
fmt.Println("")
blue.Println("Usage:")
Expand Down Expand Up @@ -117,12 +113,12 @@ func getPassword() []byte {
return password
}

func readPassword() ([]byte, error) {
if runtime.GOOS == "windows" {
return term.ReadPassword(int(windows.Handle(os.Stdin.Fd())))
}
return term.ReadPassword(int(syscall.Stdin))
}
// func readPassword() ([]byte, error) {
// if runtime.GOOS == "windows" {
// return term.ReadPassword(int(windows.Handle(os.Stdin.Fd())))
// }
// return term.ReadPassword(int(syscall.Stdin))
// }

func validatePassword(password1 []byte, password2 []byte) bool {
if !bytes.Equal(password1, password2) {
Expand Down
14 changes: 14 additions & 0 deletions password_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build !windows
// +build !windows

package main

import (
"syscall"

"golang.org/x/term"
)

func readPassword() ([]byte, error) {
return term.ReadPassword(int(syscall.Stdin))
}
15 changes: 15 additions & 0 deletions password_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//go:build windows
// +build windows

package main

import (
"os"

"golang.org/x/sys/windows"
"golang.org/x/term"
)

func readPassword() ([]byte, error) {
return term.ReadPassword(int(windows.Handle(os.Stdin.Fd())))
}

0 comments on commit 0efcd7a

Please sign in to comment.