Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Security Introduction to Data Security Solutions Storing Passwords

Declan Smith
Declan Smith
453 Points

Shake_128 issues

I entered hashlib.shake_128(b'Treehouse').hexdigest(20) and get back an error stating that there is no Attribute called shake_128

Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'shake_128'

Is my Terminal software missing anything or did I enter the wrong thing into Python?

simhub
simhub
26,543 Points

hi Declan,
i'm getting the same error on screen.
don't know the solution jet :(
maybe it has something todo with the OpenSSL library that Python uses on your/my platform - https://docs.python.org/3/library/hashlib.html

i keep following this threat maybe some one got the answer soon

2 Answers

Andrew Merrick
Andrew Merrick
20,151 Points

I've also gotten the same error but the machine I used had only Python 2.7 and, I believe, that shake_128 only works with Python 3. Not 100% accurate on that since the only documentation I can find is for Python 3.6.1.

Really cool lesson though!

Andrea Gomez
Andrea Gomez
8,609 Points

Hey guys, openssl is now available so shake_128 works now, you may want to check it out! :)

Dorota Parzych
Dorota Parzych
5,706 Points

Still can't solve it... and I want to work on my Mac... should I upgrade somehow Python to the Python 3 version then?

Andrea Gomez
Andrea Gomez
8,609 Points

You have to import hashlib in order to use shake_128 so you should do the following:

>>> import hashlib
>>> hashlib.shake_128(b'Treehouse').hexdigest(20)
>>> '16254ff15a16c961a2e87bf54d2ddac477f1d0a1'

You can read more about shake_128 and hashlib in the official documentation

simhub
simhub
26,543 Points

hi Andrea Gomez,
Which OpenSSL / Python version are you on?

Declan Smith
Declan Smith
453 Points

I had imported it originally to use for md5 and sha256, they both worked fine. Once I tried to use shake_128 I received the error message.

Andrea Gomez
Andrea Gomez
8,609 Points

Hi, I'm using OpenSSL 1.1.0.f-1 25 May 2017 and Python 3.6.1 in Arch Linux.

I've just tried it using a Python workspace and I think that the problem is that openssl is not installed by default in workspaces, if you try to do it using the Treehouse console you'll notice that the OpenSSL version installed is 1.0.1 from 14 mar 2012 and it does not work with that one either and it can't be updated using apt-get.

I've already sent a message to support to see if they can install OpenSSL in workspaces in order to try shake_128 from a Python workspace, I'll keep you updated. :)