Hack the planet!!...With Python

So I'm sat watching a film called Hackers...cheesy hacker movie set in the 1990s. But I really do like it. Sure the dialogue is really bad, and the hacking is pure Hollywood, but it is a fascinating

Everyone has handles, nicknames based on their skills.

But what would your hacker handle be?

Well with Python we can make our own Hacker Handle and here is how.

Coding the project

alt

I wrote this project using Trinket.io so that I can embed working code into this web page. But you can easily write this code on your Raspberry Pi, PC, Mac using Python 3 editor (IDLE3) or using another Python editor (PyCharm, Sublime Text etc)

Imports

In Python we start by importing something called "shuffle" from a library called random...but what does that mean? Python has a library, pre-written code that contains extra functionality. In this case the random library contains code to create random numbers, random choice, and importantly for us...shuffling data as if we were shuffling a deck of cards. Because we just need the shuffle functionality we shall import the library a little differently to normal.

from random import shuffle  

Lists, the most powerful tool on the planet

With that complete we now create a list of cool hacker handles. In Python a list is a form of data storage. We can store lots of different types of data, such as

  • Strings - Our hacker handles are strings
  • Integers - Numbers with no decimal place
  • Floats - Numbers with a decimal place

A list uses an index to allocate a position to each item in the list. For example the first item in a list has an index of 0, and then each new item receives an index that increases by 1.
In the code below, handles[0] is "Zero" and handles[10] is "Burn".

handles = ["Zero",  
          "Acid",
          "Max",
          "Random",
          "Giga",
          "Absolute",
          "Cool",
          "Gibson",
          "Cereal",
          "Killer",
          "Burn",
          "Crash",
          "Override",
          "Razor",
          "Blade",
          "Polaroid",
          "Pi"]

Everybody's shuffling....

So now that we have our list of cool hacker handles, lets use the shuffle functionality to...shuffle the names. To do that we call the shuffle function, and pass the name of the list to it inside parenthesis ( ), this is called an "argument" and it is used to pass extra information to a function.

shuffle(handles)  

Hack the planet with ASCII art!!!!

Hackers love to use ASCII (American Standard Code for Information Interchange) art in their hacks...well that's what Hollywood taught me. So I created my own homage to that.

print("""

HH   HH                kk  
HH   HH   aa aa   cccc kk  kk  
HHHHHHH  aa aaa cc     kkkkk  
HH   HH aa  aaa cc     kk kk  
HH   HH  aaa aa  ccccc kk  kk

TTTTTTT hh  
  TTT   hh        eee  
  TTT   hhhhhh  ee   e 
  TTT   hh   hh eeeee  
  TTT   hh   hh  eeeee 

PPPPPP  lll                        tt    !!!  
PP   PP lll   aa aa nn nnn    eee  tt    !!!  
PPPPPP  lll  aa aaa nnn  nn ee   e tttt  !!!  
PP      lll aa  aaa nn   nn eeeee  tt  
PP      lll  aaa aa nn   nn  eeeee  tttt !!! 

""")

You can make you own via this website

Who am I?

So what is my hacker handle? Obviously mine has to be "Pi Killer" because of my love for Greggs pies... but what is your hacker handle?

Well to find out we use a print function, and inside the function we write a string to say "Your hacker handle is" and then we print the values stored in the "handles" list, specifically those stored at index 0 and 1. Now these values are shuffled every time the code is run, so you should see a different name each time.

print("Your hacker handle is",handles[0],handles[1])  

So if you are following along at home, run the code in your Python editor to see your cool hacker handle.

Or you can give the code below a try :)