Skip to content

Instantly share code, notes, and snippets.

View cod3smith's full-sized avatar
🤩
Always Be Coding, Always Be Learning

Kelyn Paul Njeri cod3smith

🤩
Always Be Coding, Always Be Learning
View GitHub Profile
from Crypto.Cipher import AES
import os
encryption_key = os.urandom(16)
def encrypt_AES(key, data):
cipher = AES.new(key, AES.MODE_ECB)
return cipher.encrypt(data)
def decrypt_AES(key, encrypted_data):
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa, padding
from cryptography.hazmat.primitives import hashes
# Generate RSA key pair
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048
)
public_key = private_key.public_key()
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"io"
"os"
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/pem"
from Crypto.Cipher import AES, PKCS1_OAEP
from Crypto.PublicKey import RSA
from Crypto.Random import get_random_bytes
from Crypto.Util.Padding import pad, unpad
def generate_rsa_key_pair():
key = RSA.generate(2048)
private_key = key.export_key()
public_key = key.publickey().export_key()
class Node:
def __init__(self, value):
self.value = value
self.next = None
self.down = None
class DecisionMatrix:
def __init__(self, rows, columns):
self.rows = rows
self.columns = columns
class TrieNode:
def __init__(self):
self.children = {}
self.output = []
class AhoCorasick:
def __init__(self):
self.root = TrieNode()
def add_pattern(self, pattern):
package main
import (
"fmt"
)
type TrieNode struct {
children map[rune]*TrieNode
fail *TrieNode
output []string
class Edge:
def __init__(self, v, flow, capacity, reverse_edge):
self.v = v
self.flow = flow
self.capacity = capacity
self.reverse_edge = reverse_edge
class Graph:
def __init__(self, vertices):
self.adjacency = [[] for _ in range(vertices)]