<commit_before>#!/usr/bin/env python
import socket, threading
import string

row_format ="{:>20}" * 2

class Cipher():

    def cipherGreeting(self):
        clientsock.send(row_format.format("Explain", "Encrypt!") + "\n")
        clientsock.send(row_format.format("-------", "--------") + "\n")
        clientsock.send(row_format.format("a", "b") + "\n")
        clientsock.send("Enter choice (q to exit to main menu): ")
        choice = 't'
        while len(choice):
            choice = clientsock.recv(2048).strip()
            if choice == 'a':
                self.explain()
            elif choice == 'b':
                self.encrypt()
            elif choice == 'q':
                return

class ShiftCipher(Cipher):

    def explain(self):
        clientsock.send("The shift cipher is a type of substitution cipher.\n")
        clientsock.send("Every letter in the plaintext gets replaced by another letter at a fixed distance 'k' from the letter. Here, 'k' is our 'key', and is constant for all letters in the plaintext.\n")
        clientsock.send("For example, a plaintext of 'ieee' with key 'k' = 3 would be encrypted as 'lhhh'.\n\n")
        clientsock.recv(2048)
        self.cipherGreeting()

    def encrypt(self):
        alphabet = 'abcdefghijklmnopqrstuvwxyz'
        clientsock.send("Enter plaintext: ")
        ptext = clientsock.recv(2048)
        clientsock.send("Enter shift: ")
        shift = int(clientsock.recv(2048))
        table = string.maketrans(alphabet, alphabet[shift:] + alphabet[:shift])
        clientsock.send("Ciphertext: " + ptext.translate(table))
        clientsock.recv(2048)
        self.cipherGreeting()

class ClientThread(threading.Thread):

    def __init__(self,ip,port):
        threading.Thread.__init__(self)
        self.ip = ip
        self.port = port
        print "[+] New thread started for "+ip+":"+str(port)

    def run(self):    
        print "Connection from : "+ip+":"+str(port)
        data = "dummydata"

        while len(data):
            mainMenuPrompt = 'Welcome!\nHere you can learn about different encryption schemes\nand use them to encrypt your plaintext! Have fun!\nEnter the appropriate number to continue.\n\n'

            clientsock.send(mainMenuPrompt)
            clientsock.send(row_format.format("Serial Number", "Encryption Scheme") + "\n")
            clientsock.send(row_format.format("-------------", "-----------------") + "\n")
            clientsock.send(row_format.format("1", "Shift Cipher") + "\n\n")<commit_msg>shift cipher encryption is manual<commit_after>#!/usr/bin/env python
import socket, threading

row_format ="{:>20}" * 2

class Cipher():

    def cipherGreeting(self):
        clientsock.send(row_format.format("Explain", "Encrypt!") + "\n")
        clientsock.send(row_format.format("-------", "--------") + "\n")
        clientsock.send(row_format.format("a", "b") + "\n")
        clientsock.send("Enter choice (q to exit to main menu): ")
        choice = 't'
        while len(choice):
            choice = clientsock.recv(2048).strip()
            if choice == 'a':
                self.explain()
            elif choice == 'b':
                self.encrypt()
            elif choice == 'q':
                return

class ShiftCipher(Cipher):

    def explain(self):
        clientsock.send("The shift cipher is a type of substitution cipher.\n")
        clientsock.send("Every letter in the plaintext gets replaced by another letter at a fixed distance 'k' from the letter. Here, 'k' is our 'key', and is constant for all letters in the plaintext.\n")
        clientsock.send("For example, a plaintext of 'ieee' with key 'k' = 3 would be encrypted as 'lhhh'.\n\n")
        clientsock.recv(2048)
        self.cipherGreeting()

    def encrypt(self):
        clientsock.send("Whoops! You're going to have to do this one by hand. :)\n")
        clientsock.recv(2048)
        self.cipherGreeting()

class ClientThread(threading.Thread):

    def __init__(self,ip,port):
        threading.Thread.__init__(self)
        self.ip = ip
        self.port = port
        print "[+] New thread started for "+ip+":"+str(port)

    def run(self):    
        print "Connection from : "+ip+":"+str(port)
        data = "dummydata"

        while len(data):
            mainMenuPrompt = 'Welcome!\nHere you can learn about different encryption schemes\nand use them to encrypt your plaintext! Have fun!\nEnter the appropriate number to continue.\n\n'

            clientsock.send(mainMenuPrompt)
            clientsock.send(row_format.format("Serial Number", "Encryption Scheme") + "\n")
            clientsock.send(row_format.format("-------------", "-----------------") + "\n")
            clientsock.send(row_format.format("1", "Shift Cipher") + "\n\n")
{'fraction_non_alphanumeric': 0.14961126287035093, 'fraction_numerical': 0.008825383483925194, 'mean_word_length': 2.3951497860199713, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2386447', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1405, 'n_words': 375}