LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Hashbytes

    Employee
    Posted 12-03-2015 15:57

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: pspang78

    Hi,

    I have a data column that had been hashbytes using SHA1. I understand that you can't decrypt hashbytes therefore the only way is to hashbytes the value & compare against the data from DB.

    Is there a hashbytes function in Lavastorm?


  • 2.  RE: Hashbytes

    Employee
    Posted 12-14-2015 08:53

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mgajdosik

    You can use python node for that: See the example... You may need to modify the input fields within, but does its job.
    node:Python_3
    bretype:core::Python
    editor:sortkey=561387df4af457f7
    input:5613885d5c905f77/in1=Static_Data_2.40fe6c55598828e5
    output:561387f030076ca2/out1=
    prop:Python2Implementation=<<EOX
    import braininfo
    import hashlib, binascii
    
    
    def setup(brainNodeControlObj, BrainNodeClass):
    	''' Must return a class that inherits from BrainNodeClass. '''	
    	class BrainNode(BrainNodeClass):
    		def initialize(self):
    			''' Called at node initialization, before first pump.'''
    			super(BrainNode, self).initialize()
    
    		def finalize(self, val):
    			''' Called at node end, after last pump call. '''
    			super(BrainNode, self).finalize(val)
    
    		def pump(self, quant):
    			''' Will continue to be called until False is returned.
    
    			Only a small amount of work should be done in pump without checking
    			quant.permitsRunning. When that returns False, return from pump
    			with a True value to be called again, a False value when finished.'''
    			while quant.permitsRunning(self):
    				# your code here
    				#setup metadata
    				metadata = self.newMetadata()
    				om = self.newMetadata()
    
    				#create output pins
    				om.append("Status", "string")
    				om.append("Input", "string")
    				self.outputs[0].metadata = om
    				outputRec = self.outputs[0].newRecord()
    
    				#read input pins
    				inputRec = self.inputs[0].read()
    
    				# Check that we haven't passed the last record 
    				if inputRec is None: 
    					return False
    
    				#create a record to output in output pin
    				outputRec = self.outputs[0].newRecord()
    
    
    				outputRec[0] = hashlib.sha224(inputRec["second_input"]).hexdigest()
    					
    				outputRec[1] = inputRec[0]	#using index
    				self.outputs[0].write(outputRec)
    
    				# when complete	
    				return False
    			# finished your quantum, you want pump called again
    			return True 
    	return BrainNode
    EOX
    editor:XY=580,260
    end:Python_3
    
    node:Static_Data_2
    bretype:core::Static Data
    editor:sortkey=5613888b71f17848
    output:@40fe6c55598828e5/=
    prop:StaticData=<<EOX
    single_input,second_input
    hello,this
    EOX
    editor:XY=440,260
    end:Static_Data_2