This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Caesar Cipher Python Part 1 of 2 - Encryption | |
#dictionary | |
text_id = {"a":0, "b":1, "c":2, "d":3, "e":4, "f":5, "g":6, "h":7, "i":8, "j":9, "k":10, "l":11, "m":12, "n":13, "o":14, "p":15, "q":16, "r":17, "s":18, "t":19, "u":20, "v":21, "w":22, "x":23, "y":24, "z":25} | |
id_text = {0:"a", 1:"b", 2:"c", 3:"d", 4:"e", 5:"f", 6:"g", 7:"h", 8:"i", 9:"j", 10:"k", 11:"l", 12:"m", 13:"n", 14:"o", 15:"p", 16:"q", 17:"r", 18:"s", 19:"t", 20:"u", 21:"v", 22:"w", 23:"x", 24:"y", 25:"z"} | |
#shift by a number | |
n=1 | |
#input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Tic Tac Toe Board Python | |
n = 2 | |
for j in range(n): | |
print (" "*(n+1), "|", " "*(n+1), "|") | |
print("- " * ((n+1)*2+n)) | |
for j in range(n): | |
print (" "*(n+1), "|", " "*(n+1), "|") | |
print("- " *((n+1)*2+n)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How To - perform a symmetric encryption using AES256 algorithm in Python | |
##Step 1 - use terminal and the command <pip install pycryptodome> to install a library that provides access to the AES256 algorithm. | |
##Step 2 - create an AES256 key and save it. | |
import os | |
key = os.urandom(32) | |
with open('key.bin', 'wb') as f: | |
f.write(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#How To - perform a digital signature using RSA256 algorithm in Python | |
##Step 1 - generate an RSA256 key pair (public and private keys) using the command module <Crypto.PublicKey.RSA> to generate the key pair. | |
from Crypto.PublicKey import RSA | |
key = RSA.generate(2048) | |
public_key = key.publickey() | |
print(public_key) #not sure if I need this here but I want to see the output | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Geometry - Finding the angles and area of unusual shapes | |
class Shape: # Parent Class | |
def area(self): | |
pass | |
#Triangle Subclass | |
class Triangle(Shape): | |
def __init__(self, a, b, c): | |
self.a = a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Vehicle Performance & Fuel Costs | |
#How To - Calculate Fuel Consumption | |
#Step1 - customize the behavior of drive method in ElectricCar and IceCar classes | |
#Car | |
class Car: #class = Car. Method & definition(s) are defined below this level. | |
def __init__(self, brand, milage_km): #method = __Self@Car__(parameter1, parameter2, parameter3). | |
self.brand = brand #parameter.variable = parameter. | |
self.milage_km = milage_km #parameter.variable = parameter. |