{"id":16161440,"url":"https://github.com/gamemann/tcp-app-with-encryption","last_synced_at":"2025-03-18T22:30:33.054Z","repository":{"id":92735845,"uuid":"275416236","full_name":"gamemann/TCP-App-With-Encryption","owner":"gamemann","description":"A client and server project that encrypts and decrypts messages. The client is programmed in C using the Libsodium library and the server is programmed in Elixir using ErLang's crypto module.","archived":false,"fork":false,"pushed_at":"2020-06-28T19:46:04.000Z","size":25,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T12:30:01.908Z","etag":null,"topics":["c","client","cypto","elixir","encryption","erlang","libsodium","server","tcp"],"latest_commit_sha":null,"homepage":"https://moddingcommunity.com/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gamemann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-27T16:59:44.000Z","updated_at":"2024-08-27T02:00:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0ed74f3-71a6-49ae-9010-c4fe818f937f","html_url":"https://github.com/gamemann/TCP-App-With-Encryption","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FTCP-App-With-Encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FTCP-App-With-Encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FTCP-App-With-Encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gamemann%2FTCP-App-With-Encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gamemann","download_url":"https://codeload.github.com/gamemann/TCP-App-With-Encryption/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243950813,"owners_count":20373664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","client","cypto","elixir","encryption","erlang","libsodium","server","tcp"],"created_at":"2024-10-10T02:25:16.127Z","updated_at":"2025-03-18T22:30:33.049Z","avatar_url":"https://github.com/gamemann.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TCP Application With Encryption\n## Description\nThis application serves as a TCP client =\u003e server implementation and supports writing encrypted data. This application encrypts data from the client program (user-inputted data from `stdin`) and sends it to the server. The server then decrypts the data using the same key, tag, and nonce/IV generated from the client program and outputs the decrypted text.\n\nBoth the client and server take advantage of `Chacha20_poly1305`, a symmetric cipher. A shared key is used between the client and server. This key is located at `/etc/tcpserver/key.txt` by default. You may use the `/client/genkey.c` program to generate a key that is typically 32 bytes in size.\n\nI wrote this application to practice Elixir and encryption. I plan to use a similar setup with my future Barricade Firewall [project](https://github.com/Barricade-FW).\n\n## The Client\nThe client (`/client/client.c`) is written in C and uses a library named [Libsodium](https://libsodium.gitbook.io/doc/) for encryption and hashing.\n\n### Command Line Options\n* `--dst, -d` =\u003e The IP of the server (default is `\"0.0.0.0\"`).\n* `--port, -p` =\u003e The port of the server (default is `3020`).\n* `--key, -k` =\u003e The path to the shared key file (default is `\"/etc/tcpserver/key.txt\"`).\n\n## The Server\nThe server (`/server/*`) is written in Elixir and uses the ErLang Crypto [module](https://erlang.org/doc/man/crypto.html) for decrypting data and hashing. The server utilizes GenServer.\n\n### Configuration\nYou may configure additional settings in `/server/config/config.exs`. Here is a brief description of each:\n\n* `ip` =\u003e The IP for the server to listen on (default is `{0, 0, 0, 0}`).\n* `port` =\u003e The port for the server to listen on (default is `3020`).\n* `keypath` =\u003e The path to the shared key file (default is `\"/etc/tcpserver/key.txt\"`).\n\n**Note** - The `ip` setting must be a tuple containing four elements and each element represents an octet. An example is `{127, 0, 0, 1}`.\n\n## Generating A Key\nYou may generate a key with the `/client/genkey.c` program.\n\n### Command Line Options\n* `--path, -p` =\u003e The path to save the file to (default is `\"/etc/tcpserver/key.txt\"`).\n\n## Requirements\n### Client\nThe client requires Libsodium to be installed on the system. Please read the installation instructions [here](https://libsodium.gitbook.io/doc/installation).\n\n### Server\nThe server only requires ErLang and Elixir to be installed on the system. You shouldn't need to install anything else because we don't use any third-party dependencies. To be safe, you may execute the following:\n\n```\ncd server/\nmix deps.get\n```\n\n**Note** - I installed ErLang, Elixir, and the server on a vanilla Ubuntu 20.04 VM and it ran the first time without any issues.\n\n## Compiling\n### Client and GenKey\nYou may use GCC to compile the client and genkey programs:\n\n```\ngcc -g client/client.c -o client -lsodium\ngcc -g client/genkey.c -o genkey -lsodium\n```\n\nPlease note you must link Libsodium which is done in the above via `-lsodium`.\n\n## Running\n### Client and GenKey\nYou can easily run the GenKey and Client programs via:\n\n```\n./genkey\n...\n\n./client\n```\n\n### Server\nRunning the server is simple. Please execute the following commands:\n\n```\ncd server/\niex -S mix\n```\n\n## Credits\n* [Christian Deacon](https://www.linkedin.com/in/christian-deacon-902042186/) - Created application.\n* [Dreae](https://github.com/Dreae/) - Helped me understand the `Chacha20_poly1305` cipher and encryption. He has been a HUGE help!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Ftcp-app-with-encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgamemann%2Ftcp-app-with-encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgamemann%2Ftcp-app-with-encryption/lists"}