aboutsummaryrefslogtreecommitdiff
path: root/weed/util/cipher.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-13 23:53:15 -0700
committerChris Lu <chris.lu@gmail.com>2020-03-13 23:53:15 -0700
commite2e691d9c23d2b18b032f4d464ca0756c134ed87 (patch)
treedfb24f246b781ed620454d70c03e604dec662ea2 /weed/util/cipher.go
parent7213f446db011334d57c49b9b96a8ba58929228b (diff)
downloadseaweedfs-e2e691d9c23d2b18b032f4d464ca0756c134ed87.tar.xz
seaweedfs-e2e691d9c23d2b18b032f4d464ca0756c134ed87.zip
clean up, add test
Diffstat (limited to 'weed/util/cipher.go')
-rw-r--r--weed/util/cipher.go21
1 files changed, 0 insertions, 21 deletions
diff --git a/weed/util/cipher.go b/weed/util/cipher.go
index 7bcb6559a..f044c2ca3 100644
--- a/weed/util/cipher.go
+++ b/weed/util/cipher.go
@@ -1,14 +1,11 @@
package util
import (
- "bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
- "fmt"
"io"
- "io/ioutil"
"github.com/chrislusf/seaweedfs/weed/glog"
)
@@ -61,21 +58,3 @@ func Decrypt(ciphertext []byte, key CipherKey) ([]byte, error) {
nonce, ciphertext := ciphertext[:nonceSize], ciphertext[nonceSize:]
return gcm.Open(nil, nonce, ciphertext, nil)
}
-
-func EncryptReader(clearReader io.Reader) (cipherKey CipherKey, encryptedReader io.ReadCloser, clearDataLen, encryptedDataLen int, err error) {
- clearData, err := ioutil.ReadAll(clearReader)
- if err != nil {
- err = fmt.Errorf("read raw input: %v", err)
- return
- }
- clearDataLen = len(clearData)
- cipherKey = GenCipherKey()
- encryptedData, err := Encrypt(clearData, cipherKey)
- if err != nil {
- err = fmt.Errorf("encrypt input: %v", err)
- return
- }
- encryptedDataLen = len(encryptedData)
- encryptedReader = ioutil.NopCloser(bytes.NewReader(encryptedData))
- return
-}