コード例 #1
0
ファイル: randomcaesarcipher.py プロジェクト: bensoer/pychat
    def __init__(self, arguments):
        seed = ArgParcer.getValue(arguments, "-s")
        offset = ArgParcer.getValue(arguments, "-o")

        'set the seet value if it was passed in'
        if(seed != ""):
            self.__seed = int(seed)

        'set the offset value if it was passed in'
        if(offset != ""):
            self.__offset = int(offset)

        'now generate our scrambled alphabet'
        self.__generateScrambledAlphabet()
コード例 #2
0
ファイル: caesarcipher.py プロジェクト: bensoer/pychat
    def __init__(self, arguments):

        # if they pass an o parameter, use this as the offset value
        offset = ArgParcer.getValue(arguments, "-o")
        if offset == "":
            self.offset = 3
        else:
            self.offset = int(offset)
コード例 #3
0
ファイル: aescipher.py プロジェクト: bensoer/pychat
 def __init__(self, arguments):
     # if they pass a k parameter, use as the password
     password = ArgParcer.getValue(arguments, "-k")
     while password == "":
         password = input("AES needs a passkey: ")
     # this is not actually going to be used as the passkey for AES
     # we are going to create a 256bit key from the given secret password
     h = SHA256.new()
     h.update(bytes(password, 'utf-8'))
     self.key = h.digest()
コード例 #4
0
ファイル: transpositioncipher.py プロジェクト: bensoer/pychat
    def __init__(self, arguments):
        key = ArgParcer.getValue(arguments, "-k");
        if key == "":
            raise AttributeError("Key Is Required Parameter For Transposition Cipher");
        else:
            self.__key = key

        # add the key as a list
        self.__mapper = list()
        self.__mapper.append(list(self.__key))

        positionsList = self.__createAlphabeticalIndexListOfKey(self.__key)

        #print(positionsList)
        self.__mapper.append(positionsList)
コード例 #5
0
ファイル: pychat.py プロジェクト: bensoer/pychat
-h host to connect to
-p port to connect to host on

-lp port to listen on

-u [optional] set the username of the user. default is a random generated number
-a set encryption and decrytion algorithm
'''





arguments = sys.argv
'fetch the arguments we need'
host = ArgParcer.getValue(arguments, "-h")
port = int(ArgParcer.getValue(arguments, "-p"))
listeningPort = int(ArgParcer.getValue(arguments, "-lp"))
username = ArgParcer.getValue(arguments, "-u")
algorithm = ArgParcer.getValue(arguments, "-a")

'configure username if it was defined'
if username == "":
    username = str(random.random())

'create the socket to communicate over'
clientSocket = socket(AF_INET, SOCK_DGRAM)
clientSocket.bind(('localhost', listeningPort))

'setup cryptor'
cryptor = Cryptor()
コード例 #6
0
from netprocess import NetProcess
import socket
import sys
import fcntl
import os
from tools.argparcer import ArgParcer


arguments = sys.argv
if len(arguments) <= 1:
    # print out help or something
    print("ERROR. NO ARGUMENTS PASSED. PARAMETERS REQUIRED TO OPERATE")
    sys.exit(1)

#fetch the arguments we need
address = ArgParcer.getValue(arguments, "-h")
port = ArgParcer.getValue(arguments, "-p")

if address == "" or port == "":
    print("ERROR. ADDRESS AND PORT PARAMETERS ARE REQUIRED")
    sys.exit(1)

config_data = {"address": (address, port)}
send_pipe = os.pipe()
recv_pipe = os.pipe()

pid = os.fork()
if pid == 0:
    print("IN CHILD PROCESS")
    # this is the child process
    net_manager = NetProcess(config_data, recv_pipe, send_pipe)