def calculate_force(self, particle, node=None): if node is None: node = self.root force = Vector2d(0, 0) if len(node.particles) == 0: return force if (node.type == 2) and (node.particles[0] != particle): tmp_f = forces.base_force(particle, node.particles[0]) # print(particle.name, node.name, node.depth, len(node.particles)) force += tmp_f cm = node.get_cm() if (node.type == 1) and (mac.mac(particle, node)): # print(particle.name, node.name) # print(particle.name, node.name, node.depth, len(node.particles)) tmp_f = forces.base_force(particle, Particle(r=cm, v=node.get_mv(), mass=node.mass)) force += tmp_f if (node.type == 1) and not(mac.mac(particle, node)): for child in node.children: force += self.calculate_force(particle, child) return force
def calculate_force(self, particle, node=None): if node is None: node = self.root force = Vector2d(0, 0) if len(node.particles) == 0: return force # if (node.type == 2) and (abs(node.particles[0].r - particle.r) != 0): if (node.type == 2) and (node.particles[0] != particle): tmp_f = forces.base_force(particle, node.particles[0]) # print(particle.name, node.name, node.depth, len(node.particles)) # if particle.name == constants.median: # tmp_brute_f = Vector2d() # for particle_brute in node.particles: # tmp_brute_f += forces.base_force(particle, particle_brute) # # len_error = (abs(tmp_f) - abs(tmp_brute_f)) / (abs(tmp_brute_f) + constants.epsilon) # print(len_error, '|', tmp_f, '|', tmp_brute_f) force += tmp_f cm = node.get_cm() if (node.type == 1) and (mac.mac(particle, node)): # print(particle.name, node.name) # print(particle.name, node.name, node.depth, len(node.particles)) tmp_f = forces.base_force( particle, Particle(r=cm, v=node.get_mv(), mass=node.mass, name='aprox')) a = 0.1 b = 0.8 tmp_color = ((b - a) * np.random.random() + a, (b - a) * np.random.random() + a, (b - a) * np.random.random() + a) self.save_particles += len(node.particles) - 1 for particle_color in node.particles: particle_color.color = tmp_color if particle.name == constants.median: tmp_brute_f = Vector2d() for particle_brute in node.particles: tmp_brute_f += forces.base_force(particle, particle_brute) len_error = (abs(tmp_f) - abs(tmp_brute_f)) / ( abs(tmp_brute_f) + constants.epsilon) print(len_error, '|', tmp_f, '|', abs(tmp_f), '|', tmp_brute_f, '|', abs(tmp_brute_f)) force += tmp_f if (node.type == 1) and not (mac.mac(particle, node)): for child in node.children: force += self.calculate_force(particle, child) return force
def main(dummy_mac=[]): macs = mac() if dummy_mac != []: macs = dummy_mac # print("IP MAC Vendor Name") for k in macs.keys(): try: mac_address = macs[k] # print("[+] Checking Details...") vendor_name = get_mac_details(mac_address) print(f"{k} {mac_address} {vendor_name}") except: print('Something went wrong') time.sleep(2)
def macstd(self, el1, el2, macchang, caller): """controls calculation of mass absorption coefficients for compound standards.""" xmu = mac(el1, el2) if macchang == 'Y': mess = ('+MAC for %s %s in %s is %.4g\nChange to:(def.=current)' % (el1.name, el1.line, el2.name, xmu)) if caller == 'B': mess = mess + 'XRF, Compd. Stnd.:' if caller == 'C': mess = mess + 'Compound Standard:' if caller == 'P': mess = mess + 'Pure Element Stnd:' if caller == 'F': mess = mess + 'Addl. XRF, Sample:' xmu = get_nums(mess, 10e10, 0, xmu) print '+Changed to %.4g' % xmu return xmu
def main_mac(Demo=True, dummy= {} ): if Demo: macs= dummy else: macs = mac() dic = {} ip_list = [] m_list = [] vendor_list = [] loc_list = [] df = get_vendor_details() for ip,m in zip(macs.keys(), macs.values()): mac_ids =m[:8] nes = mac_ids.replace(':','') search = f'{nes.upper()}' # print(search) ip_list.append(ip) m_list.append(m) ans = df[df.Assignment == search] vendor = str(ans['Organization Name'])[6:-40].lstrip() l = str(ans['Organization Address'])[6:].strip() loc =l.replace(' \nName: Organization Address, dtype: object','') # print(vendor) if '([],' in vendor: vendor_list.append('Not Discovered') loc_list.append('Not Discovered') # n.append(ans['Organization Name']) else: vendor_list.append(vendor) loc_list.append(loc) dic['ip'] = ip_list dic['mac adresses'] = m_list dic['vendor'] = vendor_list dic['location'] = loc_list df2 = pd.DataFrame(dic) print(df2)
continue # Add a time stap to the message to void replay attacks message = message + " -" + str(int(time.time())) # Gererate random quadratic residuosity x0 = random.randint(100001, 1000001) # Encrypt the message if (select == "BLUM"): cipher = enc.Blum_Gold_Encrypt(n_bank, x0, message) elif (select == "DES"): cipher = DES.encrypt(message, key) else: # 3 DES cipher = DES.encrypt3(message, key) # Get the MAC mac = HMAC.mac(message, key) # # Send over the Encrypted message send = cipher + " MAC = " + mac print("Sending the ciphertext:", send) s.send(send.encode()) print() # Recieve Response data = s.recv(1024).decode("utf-8") data_no_mac = data[:data.index("M") - 1] # print(data_no_mac) if quitFlag == False: print(data) if (select == "BLUM"): msg = enc.Blum_Gold_Decrypt(n, a, b, p, q, data)
alg_params['critic_num_h'] = 1 alg_params['critic_|h|'] = 64 alg_params['critic_lr'] = 0.005 alg_params['actor_num_h'] = 1 alg_params['actor_|h|'] = 64 alg_params['actor_lr'] = 0.0005 alg_params['critic_batch_size'] = 32 alg_params['critic_num_epochs'] = 10 alg_params['critic_target_net_freq'] = 1 alg_params['max_buffer_size'] = 5000 alg_params[ 'critic_train_type'] = 'model_free_critic_TD' #or model_free_critic_monte_carlo #ensure results are reproducible numpy.random.seed(meta_params['seed_number']) random.seed(meta_params['seed_number']) session_conf = tf.ConfigProto(intra_op_parallelism_threads=1, inter_op_parallelism_threads=1) from keras import backend as K tf.set_random_seed(meta_params['seed_number']) sess = tf.Session(graph=tf.get_default_graph(), config=session_conf) K.set_session(sess) meta_params['env'].seed(meta_params['seed_number']) #ensure results are reproducible #create a MAC agent and run agent = mac.mac(alg_params) agent.train(meta_params) #create a MAC agent and run
data = c.recv(1024).decode() data_no_mac = data[:data.index("M") - 1] print("Recieved:", data) # Decrypt if (select == "BLUM"): msg = enc.Blum_Gold_Decrypt(n, a, b, p, q, data) elif (select == "DES"): msg = DES.decrypt(data_no_mac, key) else: # 3 DES msg = DES.decrypt3(data_no_mac, key) # Get the mac the ATM send over user_mac = enc.parse_mac(data) # Get the mac of the message mac = HMAC.mac(msg, key) message = msg[:msg.index("-")] # Get the time stap of the message time_msg = int(msg[msg.index("-") + 1:]) # Check that the MAC and TimeStamp Match if (mac == user_mac and (time_msg < time.time() + 1)): returnVal = -1 if msg[0:7] == "Deposit": returnVal = bank.deposit(round(float(msg[8:msg.index("-") - 1]), 2)) elif msg[0:8] == "Withdraw": returnVal = bank.withdraw( round(float(msg[9:msg.index("-") - 1]), 2))