[I] from codeberg.org
Find a file
2026-03-24 14:01:57 -04:00
client.py initial commit 2026-03-24 13:47:16 -04:00
README.md readme update 2026-03-24 14:01:57 -04:00
requirements.txt forgot requirements 2026-03-24 13:58:02 -04:00
server.py initial commit 2026-03-24 13:47:16 -04:00

pyNaCL Chat

Trying to work encryption into a standard TCP socket chat application using pyNaCl (pysodium).

Setup/Running:

VirtualEnv Setup:

on linux:

python3 -m venv naclchat

cd naclchat/bin

source activate

you should see:

(naclchat) <username>@<hostname>:<path>

clone the repo:

git clone https://codeberg.org/left4code/pyNaCl-chat

mv pyNaCl-chat/* .

pip install -r requirements.txt

Running The Server:

python3 server.py

port?: <unregistered port>

^__^
(oo)\_______
(__)\       )\/
    ||----w |
    ||     ||
      cowRC

violating port #<unregistered port>
"IRC, but sort of encrypted."

choose the port on localhost you want to run the server.

Leave this running, this broadcasts all user's messages!

Running The Client:

This project supports two clients.

In a new terminal, activate the virtual environment again with source activate python3 client.py

                    .-""-.
                   / .--. \
                  / /    \ \
                  | |    | |
                  | |.-""-.|
                 ///`.::::.`\
                ||| ::/  \:: ;
                ||; ::\__/:: ;
                 \\\ '::::' /
                  `=':-..-'`

             [Usage:]             
#1: connect to the server port
#2: run !KEY! on both clients
#3: run !E then your message to encrypt a message
Note: you can send unencrypted messages just by typing

Repeat this one more time.

Client Usage:

Enter the port that you selected for the server, along with your client name. You should see that you joined the server, from here you will want to do the same on the other client.

Key exchange

To exchange keys with the other client, Enter !KEY! into the chat

on the other client you should see the public key be received

repeat this process on the other client

Message sending

To send an encrypted message, Enter !E <your message>, sends it to the server, then it's broadcast to all clients.

Viewing Traffic

You can open wireshark, and look on your loopback interface, search for the port number you are using to connect to the server.

Inside the data section of the TCP packet, you should see unencrypted data if you didn't use !E, and scrambled data if you did!

ToDo (Hopefully)

  • implement qt6 gui for the client, make things look better, get some experience with it
  • convert the entire program from functional to class-based.
  • do a silly little blog about it