DEV Community

Cover image for Benefits of GitHub - Learning 10+ python packages in half a week!
Phantz
Phantz

Posted on • Updated on

Benefits of GitHub - Learning 10+ python packages in half a week!

So, you might be asking yourself, open source is beneficial and all but learning 10+ python packages in half a week? what gives?

It was all thanks to this year's hacktoberfest and all the projects that I got to work on during it. I worked on zairza-website by zairza-website, pizza-ordering by Aniketh01, ms by Sacules and traxss by m4cs. That last one is important, you'll find out why soon.

All that inspired me to work on my own pet projects a lot of which I published to my own GitHub. Through that I advanced my knowledge with Python, Java, C and ES6.

Ok so, now for the real deal. Remember traxss? the project I mentioned above? I contributed a lot of code to it and sort of became a welcome contributor to m4cs. Earlier this week, after a long time of inactivity, I noticed a new repo on their profile - pixcryption! I got excited seeing that as it seemed interesting to me. But it was using PIL, numpy, uuid and itertools. I didn't have experience with any of them beforehand.

But when I saw it had an issue open about implementing AES encryption (something I didn't even know about), I couldn't hold in my curiosity. I read up on it immediately, saw Pycryptodome and asked m4cs to assign me to it!

Ofcourse, Pycrptodome wouldn't cut it all, all the keys and necessary info needed to be stored in tuples of integers (range being from 0 to 255) representing each pixel. And since each key was a byte_string some of 15 bytes and some of 16, it wouldn't be an easy task to store them in tuples. And so, I got to reading more and eventually I figured it out. Using itertools, I converted the byte_str into a list and then basically turned the whole list into a list of tuples of 3 integers and I filled the empty tuple slots with 0. So a list of 4 integers like this:- [1, 2, 3, 4] would convert into = [(1, 2, 3), (4, 0, 0)]. Eventually I got everything sorted out and pixcryption now has AES encryption along with base64 encoding to boast!

Things I learned from pixcryption:-

  • PIL (in general)
  • numpy.array()
  • itertools.product() and itertools.zip_longest()
  • AES encryption/decryption
  • base64 encoding/decoding

I got in good terms with the creator of pixcryption, m4cs, now. So I got to work on his latest service jsonsty. He asked me to implement data encryption before storage and decryption after retrieval. But this is a flask web app and also uses a REST api that I'll also have to tweak. Unfortunately, I knew neither.

So I got in reading and testing again. I first got accustomed to flask web apps and how to run it on localhost and how to debug it an what not and then ran through the code. I've always been a believer of the quote Practical experience is always better than theoretical and I can definitely say that working hands on with this app along with fetching the docs here and there, I got accustomed to flask way faster than I would've without an actual working web app. I then had to get familiar with pymongodb, which was also fairly straightforward due to to the web app being a live example. After I felt comfortable with the code, I found it easy to implement the encryption/encode and decode/decryption functions, which were already in place at pixcryption, in the web app.

But here's the final challenge, the front_end of the web app expects a python dict object in json format. But that is impossible (or atleast tough to implement) given the fact that python represents strings with a single quote instead of a double quote that .json format requires. This made me read in depth into python's json library because at first I couldn't even figure out why it was returning clearly json formatted objects with a single quote. I ended up storing the data as python dict in backend but using json.dumps() to get a string for the front_end.

After that, I read up a bit on flask.jsonify() and requests for handling the REST api and tweaked that to work with the encryption/decryption as well. The api returns the python dict object itself upon request. Then either jsonify() or json.dumps() can be used to represent that into proper/required format.

Later, I was asked to patch up the unittest for the api and through that I got to run my first ever unit tests in python!

SUCCESS!! The unit tests passed!
And The web frontend works like a charm!

Things I learned from jsonsty:-

  • flask (in general)
  • pymongodb (in general)
  • REST API
  • json
  • unittest

But wait the gifts don't end! By my friends in the open source community I was recommended to check out liboqs by open-quantum-safe and awesome-cryptography by sobolevn. These are also 2 phenomenal pieces of open source projects!

And just like that, I learnt ALL THOSE in half a week! And I sincerely believe anyone can do just the same. Whether you use the links I provided here to learn (e.g the ongoing pixcryption, jsonsty) or something else from the endless sea of great open source projects that I'm sure you'll find. Just remember, learning something practically is gonna bring down your time to learn it exponentially!

Top comments (2)

Collapse
 
theooliveira profile image
Theo Oliveira

Thanks for the tip. I had sort of similar experience. I had a test at work to do to get a better position. It took 10 days to complete due the lack but after I finished it felt so good that I am really into give a try to more challenges. Your post gave more hype to do it. I will check some projects to work it. I am.pretty new so I lack a lot of knowledge about things but Ive been trying

Collapse
 
m4cs profile image
Max Bridgland

You are by far one of my favorite people to work with and I'm so happy my projects helped you learn new things it was great being there to see you figure new things out over the past week or so. Seriously thank you so much for everything you have done to help out!!