This collection of C programs implements a client-server architecture for encrypting and decrypting ASCII text using a one-time pad encryption scheme. For information on one-time pad encryption, please see the one-time pad Wikipedia entry.
The primary purpose of this project is to demonstrate interprocess communication on *nix systems as well as to create server programs that handle client requests using child processes.
These programs are intended for use on Unix-based systems. To compile all programs, type compileall
. This will run a Bash script that produces the following executables:
otp_enc
- The one-time pad encryption client. This passes a plaintext message to an encryption server.otp_enc_d
- The one-time pad encryption server. This performs the encryption on behalf of the client.otp_dec
- The one-time pad decryption client. This passes a ciphertext message to a decryption server.otp_dec_d
- The one-time pad decryption server. This performs the decryption on behalf of the client.keygen
- Generates a key to be used in encryption and decryption.
If permission is denied for the Bash script, use chmod +x compileall
to give the script executable permissions.
otp_enc <plaintext> <keytext> <port>
plaintext
is a regular file containing text to be encrypted byotp_enc_d
.keytext
is a regular file containing keytext generated bykeygen
. keytext must be at least as long as plaintext.port
is the port number of theotp_enc_d
server.
otp_enc_d <port>
port
is the listening port forotp_enc_d
.
otp_dec <ciphertext> <keytext> <port>
ciphertext
is a regular file containing text to be decrypted byotp_dec_d
.keytext
is a regular file containing keytext generated bykeygen
. keytext must be at least as long as plaintext.port
is the port number of theotp_dec_d
server.
otp_dec_d <port>
port
is the listening port forotp_dec_d
.
keygen <len>
len
is the length of the key to be generated.
- Use
keygen
to generate keytext at least as long (in bytes) as the plaintext to be encrypted. - Run
otp_enc_d
on an unreserved port not currently in use.- It may be helpful to run this and
otp_dec_d
as background processes with&
as a suffix.
- It may be helpful to run this and
- Run
otp_dec_d
on an unreserved port not currently in use. - Encrypt the plaintext using the generated keytext by running
otp_enc
, and redirectingstdout
to a file of your choosing. - Decrypt the plaintext by running
otp_dec
on the file created in the above step and the generated keytext. - To exit the server programs, use
kill -kill <process_id>
to send SIGKILL signals to theprocess_id
of each server.
- By default, output from
otp_enc
andotp_dec
are directed tostdout
. - Capital letters and space are the only plaintext characters currently supported.
© Maxwell Goldberg 2017