Skip to main content
Hi all,

 

Does anybody have some experience in creating a SHA-256 hashcode via FME (desktop/server)? or in combination with third party software?
Hi

 

 

Its rather easy to do with Python's built-in hashlib module (https://docs.python.org/2/library/hashlib.html), something like:

 

 

--- 

 

import hashlib

 

hash = hashlib.sha256()

 

hash.update('Lorem ipsum')

 

hash.update('dolor sit amet')

 

print hash.hexdigest()

 

--- 

 

 

David
Hi David,

 

Thanks for the tip, looks promising.

 

Itay
Yep it did the trick, thanks!

Hi,

I found this question, when I was looking for something similar.

I am quite unfamiliar with Python and therefor am struggling with my solution. So far I came up with this:

import fme
import fmeobjects 
import hashlib

def processFeature(feature):
    hash = hashlib.sha256()
    strOld = feature.getAttribute('inputstring')
    hash.update(strOld)    
    strNew = hash.hexdigest()
    feature.setattribute('hashcode', strNew) 
Unfortunately, this leads to an errormessagePythonFactory failed to load python symbol `ProcessFeature'
Factory proxy not initialized
f_23(PythonFactory): PythonFactory failed to process feature
A fatal error has occurred. Check the logfile above for details
Bridge failed to output feature on tag `PYOUTPUT'
f_7(PythonFactory): PythonFactory failed to process feature

 

Help is appreciated, thanks in advance!Steven

Ha,

it seems to be about the casing in setAttribute...

Works now!

import fme
import fmeobjects
import hashlib


def processFeature(feature):
    hash = hashlib.sha256()
    strOld = feature.getAttribute('inputstring')
    hash.update(strOld)
    # hash_object = hashlib.sha256(strOld.encode())
    strNew = hash.hexdigest()
    att = 'hashcode'
    feature.setAttribute(att, strNew)



Reply