A New Broom: Python 2.7 to Python 3.8, and a Whole Lot More …

Cyber & Data, and so much more

Photo by Lasse Møller on Unsplash

A New Broom: Python 2.7 to Python 3.8, and a Whole Lot More …

Cyber & Data, and so much more

Did you know that REM’s best album was when they all swapped instruments and disrupted their approach to music. And, so, I’m a big believer in continually disrupting and innovating within my research and teaching, and to learn from the past, but to take big jumps and force yourself into new areas. As an innovator, you should never take the status quo as the normal state, as you must continually look to change and improve. Most of the time it will be small changes, but every so often you see the potential to build something new. Knowing when the best time to radically jump is the art of the true innovator.

I’m currently developing a new Data Labs funded course on Cyber & Data, and where I’m going to try and integrate Python code to teach Cybersecurity and Data Science. I also need a new foundation to support my modules, so here we go …

The times they are a changin

The world of software is changing, and we are moving towards a GitHub driven world, and where we run our software on servers, and use a Web browser to view. As a minor thing too, Python 2.7 is not going to be supported anymore, so, I’ll have a major task in upgrading my existing code. Python 2.7 code will still run, but the focus is now on moving it all forward to Python 3.7 and above.

So how do I best integrate code into the content? Well, I’ve chosen Python and Node.js as the two languages that I’ll use to support the new course (and my existing modules), as they are the most widely supported in Cybersecurity and Data Science. Look under the hood of Splunk, and you’ll find a Linux/Python integration.

So my questions are:

  • How can I support students who have limited access to a coding environment?
  • How can I easily share my code online?
  • How do I integrate code into Web pages?
  • How do I document that installs I have used?
  • How can I integrate fully into Python 3.8?

And so I’m now moving all my teaching and code towards solving these problems. Over Semester 2, I’ve run the Cryptography module from a GitHub integration [here], but I have faced a few issues with students running Python 3.7 against the code I’ve created in Python 2.7. While I installed and tested everything into a Ubtunu VM, some students wanted to build their own environment, and use Python 3.7. While the syntax differences are fairly easy to overcome, the problems of installing crypto libraries is not so easy to resolve. And, so, this is my change to sweep all of my teaching with a new broom.

Changing and moving on…

There have been quite a few times that I’ve had to make a fundamental decision to migrate my software. I did it when I moved my Cisco simulators from Flash to .NET and then to ASP.NET. The move from Flash to .NET was a major one, but luckily the choice of .NET then made it easy for me to move to ASP.NET:

So, now, I am faced with a Python problem, and where most of my code on my Asecuritysite.com web site is written in Python 2.7. Along with this, I’m developing a new Cyber & Data course, and want to get the code on-line and integrated into something that makes sure that all the libraries can be installed. This week, then, I’ve made the jump, and decided to go through ever piece of Python code, and upgrade it to Python 3.7 (and above).

The other problem I’ve had is that I get the code to run on my server, but then I forget the commands I’ve used to install the libraries. So can I find a way to document the libraries that are installed? Finally, can I support students who have a limited environment to run code remotely?

The migration and port

While the print statement conversions are fairly easy, and where I change:

print “Hello: “, str

to:

print (“Hello:”,str)

There are many other changes, and when you re-install the libraries for Python 3.7 there can be many changes in the usage of the functions in the code. And so I have turned to Repl.it to prove the code integration, and also allow for better integration into Web pages. Let’s try a Lagged Fibonacci Generator for random numbers [here]:

If this case we do not have any libraries that we integrate, so let’s try one with requires libraries to be installed. The great advantage with Repl.it is that it detects the imports and then manages the installation and adds the library to an TOML file with a version number. In this case we install pycryptodome for version 3.9.7 or newer:

Now, when we integrate the code, it automatically installs the required libraries:

And so here, are a few more:

and:

and:

And it is not just Python, we can have Node.js, C#, and most other languages.

Conclusions

It is good sometimes to go back over your code. For my teaching, everything will move to Python 3.8, and I’m going to now be able to send my students links to code, to show things running, and then for them to be able to modify and update the code. Oh, did you know that RSA does partial homomorphic encryption:

and here is ECDH in all its glory:

So, if you are interested, here are the courses that are coming up (they can be taken remotely, too):

Thank you to The Data Labs, for supporting the development of the Cyber & Data programme. Oh, here’s another one:

It will take a few weeks to update, but I now have the foundation to address the questions I’ve posed, and it will help my teaching so much, and build towards the future.

Postscript

As a teacher, I just want to teach fundamental concepts, and software brings them alive. So, go teach your kids software, as it is the future. For some reason, we are switching kids off software at school (in Scotland, Computer Science is in 19th place, and falling like a stone). With GitHub, Python, Jupyter notebooks, and on-line coding places, we should be supporting every child at school to integrate code with maths, physics, and many other subjects, but still we plod down the sample old coding route that we have done for decades. The world of software is now open to all, and there are no barriers. In GitHub, our code lives and breaths, it has a life, and where were we are building new worlds.