Skip to main content
Solved

SHA-256 hashcode


fmelizard
Contributor
Forum|alt.badge.img+17
Hi all,

 

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

Best answer by david_r

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
View original
Did this help you find an answer to your question?

5 replies

david_r
Celebrity
  • Best Answer
  • July 30, 2015
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

fmelizard
Contributor
Forum|alt.badge.img+17
  • Author
  • Contributor
  • July 30, 2015
Hi David,

 

Thanks for the tip, looks promising.

 

Itay

fmelizard
Contributor
Forum|alt.badge.img+17
  • Author
  • Contributor
  • August 1, 2015
Yep it did the trick, thanks!

Forum|alt.badge.img+1
  • January 26, 2017

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

Forum|alt.badge.img+1
  • January 26, 2017

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)



Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings