def map(self, value, **kwargs): file_name = kwargs.get('file_name') line_number = kwargs.get('line_number') key = hashing.hash((file_name, line_number)) % self.unique_keys key = '{:04}'.format(key) value = (int(value), 1) self.emit(key=key, value=value, **kwargs)
def get_output_dir(self, *args, **kwargs): """ Returns the directory in which are persisted the results of the function corresponding to the given arguments. The results can be loaded using the .load_output method. """ coerce_mmap = self.mmap_mode is not None argument_hash = hash(filter_args(self.func, self.ignore, args, kwargs), coerce_mmap=coerce_mmap) output_dir = os.path.join(self._get_func_dir(self.func), argument_hash) return output_dir, argument_hash
def get_output_dir(self, *args, **kwargs): """ Returns the directory in which are persisted the results of the function corresponding to the given arguments. The results can be loaded using the .load_output method. """ coerce_mmap = (self.mmap_mode is not None) argument_hash = hash(filter_args(self.func, self.ignore, args, kwargs), coerce_mmap=coerce_mmap) output_dir = os.path.join(self._get_func_dir(self.func), argument_hash) return output_dir, argument_hash
def get_hash(self): return hashing.hash(self.get_json())
import hashing from Wallet import Wallet from Blockchain import get_blockchain from Miner import Miner if __name__ == "__main__": print(hashing.hash("Jetzt liken und abonnieren!!! The Morpheus Tutorials :)")) w = Wallet() print(w.public_key) print(w.private_key) print(w.password) print(w.send_money([w.public_key], [50])) print(get_blockchain().get_json()) miner = Miner(own_public_key=w.public_key)
host='localhost' port=43378 # this is the server's port number, which the client needs to know port1=43379 # this is the eaves dropper's port # send some bytes (encode the string into Bytes first) message = "Hi, I want to send a message send your public key" s.sendto( message.encode('utf-8'), (host,port)) #receive the public key publicKey, addr = s.recvfrom(1024) # buffer size is 1024 bytes print("Client received publicKey [n, e] =",pickle.loads(publicKey)," from ADDR=",addr) publicKey=pickle.loads(publicKey) #hashing the message to their respective ascii value message = input("Enter the message here\n") #message = "My fridge just groned, rolled their eyes and, hissed at me:\n\"Not you again!\" " hash_message=hash(message) print("CLIENT: The hashed message ", hash_message) #encrypting sring encrypt_message = [] for i in range(0, len(hash_message)): encrypt_message.append(rsa_encrypt(hash_message[i],publicKey[0], publicKey[1])) print("CLIENT: The encrypted message is: ",encrypt_message) #send the message to the server s.sendto( pickle.dumps(encrypt_message), (host,port)) #sending message to evesdropper s.sendto(pickle.dumps(encrypt_message), (host,port1)) # see if the other side responds
def get_hash(self): return hashing.hash(json.dumps(self.get_dict()))
def get_shard(self, key, **kwargs): return hashing.hash(key) % self.shards