Automatically detect piped stdin on the root command; it doubles as input and output

This commit is contained in:
Mariano Uvalle 2023-11-10 17:01:28 +00:00
parent 3470117c31
commit 505e0e4b41
8 changed files with 71 additions and 125 deletions

View file

@ -7,11 +7,11 @@ import (
"github.com/AYM1607/ccclip/pkg/crypto"
)
func encryptForAll(plaintext string, pvk *ecdh.PrivateKey, devices []*api.Device) map[string][]byte {
func encryptForAll(plaintext []byte, pvk *ecdh.PrivateKey, devices []*api.Device) map[string][]byte {
res := map[string][]byte{}
for _, d := range devices {
key := crypto.NewSharedKey(pvk, crypto.PublicKeyFromBytes(d.PublicKey), crypto.SendDirection)
res[d.ID] = crypto.Encrypt(key, []byte(plaintext))
res[d.ID] = crypto.Encrypt(key, plaintext)
}
return res
}