mirror of https://github.com/schollz/croc.git
use hash words
This commit is contained in:
parent
1866b610fd
commit
f3523ebf36
36
connect.go
36
connect.go
|
@ -12,6 +12,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -233,7 +234,11 @@ func (c *Connection) Run() error {
|
||||||
fmt.Fprintf(os.Stderr, "Sending %s file named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name)
|
fmt.Fprintf(os.Stderr, "Sending %s file named '%s'\n", humanize.Bytes(uint64(c.File.Size)), c.File.Name)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(os.Stderr, "Code is: ")
|
fmt.Fprintf(os.Stderr, "Code is: ")
|
||||||
color.New(color.FgHiGreen, color.Bold).Fprint(os.Stderr, c.Code)
|
if runtime.GOOS == "windows" {
|
||||||
|
color.New(color.FgHiGreen, color.Bold).Fprint(color.Output, c.Code)
|
||||||
|
} else {
|
||||||
|
color.New(color.FgHiGreen, color.Bold).Fprint(os.Stderr, c.Code)
|
||||||
|
}
|
||||||
fmt.Fprintf(os.Stderr, "\n\n")
|
fmt.Fprintf(os.Stderr, "\n\n")
|
||||||
|
|
||||||
c.spinner = spinner.New(spinner.CharSets[24], 100*time.Millisecond) // Build our new spinner
|
c.spinner = spinner.New(spinner.CharSets[24], 100*time.Millisecond) // Build our new spinner
|
||||||
|
@ -413,9 +418,19 @@ func (c *Connection) runClient(serverName string) error {
|
||||||
if id == 0 {
|
if id == 0 {
|
||||||
c.spinner.Stop()
|
c.spinner.Stop()
|
||||||
fmt.Fprintf(os.Stderr, "Your public key: ")
|
fmt.Fprintf(os.Stderr, "Your public key: ")
|
||||||
color.New(color.FgHiRed).Fprintln(os.Stderr, c.keypair.Public)
|
if runtime.GOOS == "windows" {
|
||||||
|
color.New(color.FgHiRed).Fprintln(color.Output, HashWords(c.keypair.Public))
|
||||||
|
} else {
|
||||||
|
color.New(color.FgHiRed).Fprintln(os.Stderr, HashWords(c.keypair.Public))
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Fprintf(os.Stderr, "Recipient public key: ")
|
fmt.Fprintf(os.Stderr, "Recipient public key: ")
|
||||||
color.New(color.FgHiYellow).Fprintln(os.Stderr, publicKeyRecipient)
|
if runtime.GOOS == "windows" {
|
||||||
|
color.New(color.FgHiYellow).Fprintln(color.Output, HashWords(publicKeyRecipient))
|
||||||
|
} else {
|
||||||
|
color.New(color.FgHiYellow).Fprintln(os.Stderr, HashWords(publicKeyRecipient))
|
||||||
|
}
|
||||||
|
|
||||||
getOK := "y"
|
getOK := "y"
|
||||||
if !c.Yes {
|
if !c.Yes {
|
||||||
getOK = getInput("ok? (y/n): ")
|
getOK = getInput("ok? (y/n): ")
|
||||||
|
@ -584,8 +599,19 @@ func (c *Connection) runClient(serverName string) error {
|
||||||
fmt.Fprintf(os.Stderr, "Will not overwrite file!")
|
fmt.Fprintf(os.Stderr, "Will not overwrite file!")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(os.Stderr, "Your public key: %s\n", c.keypair.Public)
|
fmt.Fprintf(os.Stderr, "Your public key: ")
|
||||||
fmt.Fprintf(os.Stderr, "Sender public key: %s\n", publicKeySender)
|
if runtime.GOOS == "windows" {
|
||||||
|
color.New(color.FgHiRed).Fprintln(color.Output, HashWords(c.keypair.Public))
|
||||||
|
} else {
|
||||||
|
color.New(color.FgHiRed).Fprintln(os.Stderr, HashWords(c.keypair.Public))
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(os.Stderr, "Sender public key: ")
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
color.New(color.FgHiYellow).Fprintln(color.Output, HashWords(publicKeySender))
|
||||||
|
} else {
|
||||||
|
color.New(color.FgHiYellow).Fprintln(os.Stderr, HashWords(publicKeySender))
|
||||||
|
}
|
||||||
getOK := "y"
|
getOK := "y"
|
||||||
if !c.Yes {
|
if !c.Yes {
|
||||||
getOK = getInput("ok? (y/n): ")
|
getOK = getInput("ok? (y/n): ")
|
||||||
|
|
8
utils.go
8
utils.go
|
@ -12,8 +12,16 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/schollz/bytetoword"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// HashWords returns word after hashing
|
||||||
|
func HashWords(s string) string {
|
||||||
|
hasher := md5.New()
|
||||||
|
hasher.Write([]byte(s))
|
||||||
|
return bytetoword.EncodeToString(hasher.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
// CatFiles copies data from n files to a single one and removes source files
|
// CatFiles copies data from n files to a single one and removes source files
|
||||||
// if Debug mode is set to false
|
// if Debug mode is set to false
|
||||||
func CatFiles(files []string, outfile string, remove bool) error {
|
func CatFiles(files []string, outfile string, remove bool) error {
|
||||||
|
|
Loading…
Reference in New Issue