def GetDStream(self, request, context): to_be_digested_message = request.ToDigest # get all the words in the sentence word_list = to_be_digested_message.split(' ') for word in word_list: yield digestor_pb2.DigestedMessage(**self.get_hash(word))
def GetDigestor(self, request, context): """ Implementation of the rpc GetDigest declared in the proto file above. """ # get the string from the incoming request to_be_digested = request.ToDigest # digest and get the string representation # from the digestor hasher = hashlib.sha256() hasher.update(to_be_digested.encode()) digested = hasher.hexdigest() # print the output here print('{} -- {} is the digest for received payload of "{}"'.format( str(datetime.datetime.now()), digested, request.ToDigest)) result = { 'Digested': digested, 'WasDigested': True, 'OriginalMessage': request.ToDigest } return digestor_pb2.DigestedMessage(**result)
def GetDigestor(self, request, context): """ Implementation of the rpc GetDigestor declared in the proto file """ hasher = hashlib.sha256() hasher.update(request.ToDigest.encode()) digested = hasher.hexdigest() print(digested) result = { "Digested": digested, "WasDigested": True } return digestor_pb2.DigestedMessage(**result)
def GetDigestor(self, request, context): """ Implementation of the rpc GetDigest declared in the proto file above. """ # get the string from the incoming request. to_be_digested = request.ToDigest print(f'String to be digest received: {to_be_digested}') # digest and get the string representation # from the digestor. hasher = hashlib.sha256() hasher.update(to_be_digested.encode()) digested = hasher.hexdigest() result = {'Digested': digested, 'WasDigested': True} return digestor_pb2.DigestedMessage(**result)
def GetDigestor(self, request, context): """ Implementation of the rpc GetDigest declared in the proto file """ # get the string from the incoming request # defined in proto file (request = DigestMessage) as a argument for the service to_be_digested = request.ToDigest # do some work # digest and get the string representation from the digestor hasher = hashlib.sha256() hasher.update(to_be_digested.encode()) digested = hasher.hexdigest() # print the output here print(digested) result = {'Digested': digested, 'WasDigested': True} # defined in the proto file as a return type, takes a dict as a set of arguments return digestor_pb2.DigestedMessage(**result)