def __init__(self, N): """ Set up Conway's Game of Life and initialize a random configuration of dead and alive cells on the board. """ # dimension of grid (N*N = number of cells) self.N = N # matrix representing old generation self.old_grid = np.zeros(N * N, dtype='i').reshape(N, N) # matrix representing new generation self.new_grid = np.zeros(N * N, dtype='i').reshape(N, N) # matrix to store live neighbours of each cell self.live_neighbours_grid = np.zeros(N * N, dtype='i').reshape(N, N) # set up a random initial configuration for the grid # each point is either alive or dead, represented by integer values of 1 and 0, respectively for i in range(0, self.N): for j in range(0, self.N): if (random.randint(0, 100) < 15): self.old_grid[i][j] = 1 else: self.old_grid[i][j] = 0 # initialize encryption self.encryption = encryption.Encryption()
def __init__(self): self.verbosity = 0 self.configfile = "xfltreat.conf" self.servermode = 0 self.clientmode = 0 self.checkmode = 0 self.splitmode = 0 # split tunnelling self.ignoredependencies = 0 # ignoring missing dependencies self.short = "hsc" self.long = [ "help", "server", "client", "check", "split", "config=", "verbose=", "ignore-dependencies" ] # modules that should not be loaded self.forbidden_modules = [ "Generic_module", "Stateful_module", "Stateless_module" ] self.forbidden_modules_instance = [ Generic_module, Stateful_module, Stateless_module ] self.authentication = authentication.Authentication() self.encryption = encryption.Encryption()
from bottle import get, run from bottle.ext.websocket import GeventWebSocketServer from bottle.ext.websocket import websocket #import threading import datetime import encryption from sys import argv #users = [] #log=[] secret = 'nuncaVaodescobrr_ahah' chatRooms = {} RoomUsers = {} RoomLog = {} encry = encryption.Encryption() class ChatRoom(): def __init__(self, thread, Name): self.thread = thread @get('/') def index(): return bt.static_file('index.html', root='files/') @get('/favicon.ico') def retfavicon(): return bt.static_file('straight_lines1.jpg', root='files/')
import os import sys import encryption saltFile = sys.argv[1] password = sys.argv[2] filePath = sys.argv[3] destinationPath = sys.argv[4] encrypt = encryption.Encryption(saltFile, password) filename = os.path.basename(filePath) encryptedFilename = encrypt.encryptString(filename) print(encryptedFilename) destinationPath = os.path.join(destinationPath, encryptedFilename.decode("utf-8")) encrypt.encryptFile(filePath, destinationPath)
import sys import image_methods import encryption import decryption if __name__ == '__main__': if len(sys.argv) < 4: print('Arguments must be passed.') exit(0) if str(sys.argv[1]) == 'encrypt': model = image_methods.ImageModel(sys.argv[2], sys.argv[3], sys.argv[4]) encrypt = encryption.Encryption(model) encrypt.encrypt() elif str(sys.argv[1]) == 'decrypt': model = image_methods.ImageModel(sys.argv[3], sys.argv[2], sys.argv[4]) decrypt = decryption.Decryption(model) decrypt.decryption() else: print('Command ' + sys.argv[1] + ' not found') exit(0)
'!': '?', '-': '_', '_': '-', '(': ')', ')': '(', '%': '$', '$': '%', ' ': '&', '&': ' ', '+': '*', '*': '+' } #reading txt file where is the text for encryption with open('kafka.txt') as file: text_for_encryption = file.read() k1 = key.Key(key_to_encrypt) reversed_key = k1.createReverseKey() e1 = encryption.Encryption(key_to_encrypt, text_for_encryption) encrypted_text = e1.encrypt() print(encrypted_text) #saving encrypted message to txt file with open('encrypted.txt', 'w') as file: file.write(encrypted_text) #d1 = decryption.Decryption(reversed_key, encrypted_text) #print(d1.decrypt())
def test_init_encryption(self): key_to_encrypt = { 'a': 'q', 'b': 'v', 'c': 'x', 'd': 'z', 'e': 'y', 'f': 'w', 'g': 'u', 'h': 't', 'i': 's', 'j': 'r', 'k': 'p', 'l': 'o', 'm': 'n', 'n': 'm', 'o': 'l', 'p': 'k', 'r': 'j', 's': 'i', 't': 'h', 'u': 'g', 'w': 'f', 'y': 'e', 'z': 'd', 'x': 'c', 'v': 'b', 'q': 'a', 'A': 'Q', 'B': 'V', 'C': 'X', 'D': 'Z', 'E': 'Y', 'F': 'W', 'G': 'U', 'H': 'T', 'I': 'S', 'J': 'R', 'K': 'P', 'L': 'O', 'M': 'N', 'N': 'M', 'O': 'L', 'P': 'K', 'R': 'J', 'S': 'I', 'T': 'H', 'U': 'G', 'W': 'F', 'Y': 'E', 'Z': 'D', 'X': 'C', 'V': 'B', 'Q': 'S', '1': '5', '2': '9', '3': '8', '4': '7', '5': '6', '6': '4', '7': '3', '8': '2', '9': '1', '.': ',', ',': '.', ':': ';', ';': ':', '?': '!', '!': '?', '-': '_', '_': '-', '(': ')', ')': '(', '%': '$', '$': '%', ' ': '&', '&': ' ', '+': '*', '*': '+' } text_for_encryption = "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." e1 = encryption.Encryption(key_to_encrypt, text_for_encryption) mess = 'Given object is not instance of Encryption' self.assertIsInstance(e1, encryption.Encryption, mess)