You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
350 B
20 lines
350 B
#!/bin/bash
|
|
# Usage: send-file <port> <key> <file>
|
|
|
|
PORT=${1:-4443}
|
|
KEY="$2"
|
|
FILE=$3
|
|
|
|
IV=$(chacha20 keygen $KEY)
|
|
|
|
# Send the key and IV
|
|
KEY_IV=$( (echo $KEY && echo $IV) | gpg --encrypt --armour)
|
|
nc -l -p $PORT || exit 1 <<< $KEY_IV
|
|
|
|
echo "Sending file"
|
|
|
|
# Send the file
|
|
cat $FILE | gzip | chacha20 e $KEY $IV | nc -l -p $PORT || exit 2
|
|
|
|
echo "Sent"
|