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
from Crypto.Cipher import AES | |
from Crypto.Random import get_random_bytes | |
from Crypto.Util.Padding import pad, unpad | |
import base64 | |
key = input("Key: ").encode() | |
def encrypt(): | |
iv = get_random_bytes(AES.block_size) |
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
from Crypto.PublicKey import RSA | |
from Crypto.Cipher import PKCS1_OAEP | |
import base64 | |
def encrypt(): | |
keyfile = input("Public key file: ") | |
with open(keyfile, "r") as file: | |
data = file.read() | |
public_key = RSA.import_key(data) | |
cleartext = input("Cleartext: ").encode() |
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
# Run `pip install pycryptodome` to install Crypto library | |
from Crypto.PublicKey import RSA | |
from Crypto.Signature import pss | |
from Crypto.Hash import SHA256 | |
import base64 | |
def sign(): | |
with open("private.key", "r") as file: | |
data = file.read() | |
private_key = RSA.import_key(data) |
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
# This program finds a value for D in the RSA algorithm | |
# Given values for A and E | |
A = int(input("A: ")) | |
E = int(input("E: ")) | |
# Start at E so D will be bigger | |
n = E | |
while True: | |
n += 1 |
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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
byte pacman1[] = { | |
B01110, | |
B11111, | |
B11011, | |
B11111, | |
B11100, |
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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
void setup() | |
{ | |
lcd.begin(16, 2); | |
} | |
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
{% extends "layout.html" %} | |
{% block body %} | |
<form action="/add" method="post"> | |
<input type="text" name="task"> | |
<input type="submit"> | |
</form> | |
{% endblock %} |
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
#include <LiquidCrystal.h> | |
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); | |
void setup() | |
{ | |
// Set the size of the display | |
lcd.begin(16, 2); | |
// Print out some text | |
lcd.print("This is a really long line."); |
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
#include <Adafruit_NeoPixel.h> | |
# define PIN 2 | |
# define NUM_PIXELS 6 | |
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN); | |
void setup() | |
{ | |
pixels.begin(); | |
} |
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
import hashlib | |
import json | |
from time import time | |
class Blockchain: | |
def __init__(self): | |
self.chain = [] | |
self.pending_transactions = [] | |
self.new_block(previous_hash="1234", proof=100) |