From a6927a3143a8c63c16375199803352a2968b7126 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Thu, 19 Oct 2017 19:08:13 -0600 Subject: [PATCH] Starting to implement streaming cipher --- connect.go | 11 +++++++++-- crypto_test.go | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/connect.go b/connect.go index 7e28fe88..3789945c 100644 --- a/connect.go +++ b/connect.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "encoding/hex" "encoding/json" "fmt" @@ -370,7 +369,15 @@ func (c *Connection) sendFile(id int, connection net.Conn) { connection.Write([]byte(fillString(strconv.FormatInt(int64(chunkSize), 10), 10))) sendBuffer := make([]byte, BUFFERSIZE) - file := bytes.NewBuffer(c.File.bytes) + + // open encrypted file + file, err := os.Open(c.File.Name + ".enc") + if err != nil { + log.Error(err) + return + } + defer file.Close() + chunkI := 0 if !c.Debug { c.bars[id] = uiprogress.AddBar(chunksPerWorker).AppendCompleted().PrependElapsed() diff --git a/crypto_test.go b/crypto_test.go index c475d5ba..5a8f4f97 100644 --- a/crypto_test.go +++ b/crypto_test.go @@ -45,5 +45,4 @@ func TestEncryptFiles(t *testing.T) { } os.Remove("temp.dec") os.Remove("temp.enc") - }