Skip to content

Instantly share code, notes, and snippets.

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

Kelyn Paul Njeri TheAlchemistKE

🤩
Always Be Coding, Always Be Learning
View GitHub Profile
from collections import defaultdict
class HopcroftKarp:
def __init__(self, graph):
self.graph = graph
self.matching = {}
self.visited = set()
def bipartite_matching(self):
for u in self.graph.keys():
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)]
package main
import (
"fmt"
)
type TrieNode struct {
children map[rune]*TrieNode
fail *TrieNode
output []string
class TrieNode:
def __init__(self):
self.children = {}
self.output = []
class AhoCorasick:
def __init__(self):
self.root = TrieNode()
def add_pattern(self, pattern):
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
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()
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/pem"
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"io"
"os"
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/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)