Tutorial: Creating a visual cube encryption key using python 3.6(Part 1)

in #utopian-io6 years ago (edited)

images.png
image source
Repository: Python, Open Source Repository

Software: For software download python 3.0 compatible with your OS here

Difficulty : Beginner
What you will learn:
In this tutorial you will learn how to

  • Make a basic encryption key with cpython
  • How to edit python dictionaries using a temporary data bank as used in this tutorial.
  • How to identify and fix a few bugs in dictionary based python programs
    For my previous post in the python tutorial series
    Click Here* Creating a simple calculator using python 3.8(cpython)
    This previous post covers common bugs encountered when trying to write this code and how to fix them. It shows how to write this basic code from scratch.

Writing an encryption key with python 3.8(cpython)
Note: This tutorial is for people who have a basic knowledge of the python programming language as it does not explain every function individually.
This tutorial is the first of a series. It will cover how to deal with the encryption and decryption of a keyword entailing all that would be needed to do this.

To write this code we begin by stating what our code will do using a string function. This would give all instructions on how to go through the encryption and decryption process.
Screenshot_20180630-142944_1530365487784_1530366857425.png
The idea is to encrypt a message within a 2 by 2 encryption Rubik's cube. When solved the message withing the key will be unlocked. So after defining each rotation, we move on to defining the variables we will use for this code.
Screenshot_20180630-142944_1530365487784_1530367194617.png
Screenshot_20180630-142944_1530365516544_1530367220960.png

Screenshot_20180629-220109_1530367351510.png
This is the orientation of each keyword before encryption. In this encryption key I'd be using a keyword "sololearnyalzeee". This keyword contains 16 characters so it would require 2 cubes each containing 8 characters.
Since this python code would be using a dictionary for storing keywords. I would define a function to give an order output when printing our encrypted messages in the order they were put. This function would be called print_orderly().
Screenshot_20180630-142957_1530365557580_1530367652050.png
This function is imperative in this code to get a readable output and it can be used for any because the keywords for all codes are the same.
Next we define the rotation function, rotation(), which takes in two arguments. This is the most tedious part of the code and would involve a data bank to store values before editing them. Without the data bank, the message will be scrambled and output would be unreadable.
Screenshot_20180630-142957_1530365557580_1530367889784.png
Screenshot_20180630-143009_1530365583549_1530367934747.png
The data bank is similar to a temporary point of storage before code is changed.
Note: Make sure to define your if statements to be conditional for string inputs. This would be necessary for the part 2 of this tutorial.

For each if and elif edit the empty function "decryption _key" which would be useful for decryption the encryption process.

After this is done, save and test your code for each rotation to see if it is correct for each side.
If your code is correct, a front rotation defined by "F" should give.
Screenshot_20180630-151954_1530368450293.png
And an upward rotation defined by "U" should give
Screenshot_20180630-152000_1530368470310.png

Conclusion
Test this code multiple times for each rotation and feel free to share any bugs encountered in the comment section.

In the next tutorial we will be dealing with how to define automated encryption and in the next we will be dealing with how to make a visual representation for this program. Thanks for reading.

Sort:  

You have a minor misspelling in the following sentence:

This would be Neccesary for the part 2 of this tutorial.
It should be necessary instead of neccesary.

Thanks
I'd look into that

The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.

Hello! I find your post valuable for the wafrica community! Thanks for the great post! @wafrica is now following you! ALWAYs follow @wafrica and use the wafrica tag!

Thank you for your contribution.
This contribution will not be considered because of:

  • The code should not be in an image but in text to be possible to copy and paste to test the tutorial.

See in this link an example of a good tutorial.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 62996.10
ETH 3122.17
USDT 1.00
SBD 3.88