def down_file(self): i=0 key = hmac.new('MBiQyKxOkH'.encode('utf-8'), 'rVtNNIywrx'.encode('utf-8'), hashlib.sha1).hexdigest() AES=security.AESCipher(key) for files in self.file_list: decryptdata=security.AESCipher.decrypt(AES,files) name="./download_files/downolad_file"+str(i) with open(name, 'wb') as file: file.write(decryptdata) i=i+1 return len(self.file_list)
def make_T(self): i = 0 while i < len(self.D): self.T.append([]) self.T[i].append(self.W2[i]) key = hmac.new((self.key).encode('utf-8'), self.W2[i].encode('utf-8'), hashlib.sha1).hexdigest() ctr = 1 while ctr < len(self.D[i]): AES2 = security.AESCipher(key) encryptdata = security.AESCipher.encrypt(AES2, self.D[i][ctr]) Gfunction.G.setxi(self.GKd, self.D[i][ctr]) Gfunction.G.setxi(self.GKz, self.W2[i] + str(ctr)) Gfunction.G.setxi(self.GKx, self.W2[i]) xid = Gfunction.G.gety(self.GKd) z = Gfunction.G.gety(self.GKz) invers = 0 EDB.Extended_Euclid(self, z, self.q) if ((z * invers) % self.q != 1): EDB.Extended_Euclid(self, self.q, z) invers = self.t1 if (invers): if (self.W2[i] == "Ratchet"): print(invers) else: print("역원이 존재하지 않습니다. \n") y = (xid * invers) % self.q eysets = EYset(encryptdata, y) self.T[i].append(eysets) gy = Gfunction.G.gety(self.GKx) q = gy * xid xtag = OPRFSetup.OPRFSetup.left_to_right_binary( self.OPRFSet, self.g, q, self.p) ctr = ctr + 1 self.Xset.append(xtag) self.State.append([]) self.State[i].append(self.W2[i]) self.State[i].append(ctr) i = i + 1 return self.T
def getIds(self): self.encode_key=hmac.new(self.key.encode('utf-8'), self.Ws[0][0].encode('utf-8'), hashlib.sha1).hexdigest() AES=security.AESCipher(self.encode_key) i=0 while i<len(self.IDs): decryptdata=security.AESCipher.decrypt(AES,self.IDs[i]) print(decryptdata.decode('utf-8')) self.decryptdata.append(decryptdata.decode('utf-8')) i=i+1
def file_insert(self, file_name, open_file): f = open(open_file, 'r') file_content = f.read() # f2 = open(open_file, 'r') # file_content2 = f2.read() file_keyword = re.split("[, !?:;\\n]+", file_content) file_id = "" AES = security.AESCipher(self.Encrypt_key) encryptdata = security.AESCipher.encrypt(AES, file_content) self.clientSock.send(file_name.encode('utf-8')) time.sleep(0.1) file_content_2 = json.dumps(encryptdata) self.MTU_send(file_content_2) time.sleep(0.1) file_id = self.clientSock.recv(1460).decode('utf-8') file = open('./filelist/input.txt', 'a') file.write("\n" + file_id + ":" + ','.join(file_keyword)) file.close()