Skip to content

Instantly share code, notes, and snippets.

View facundopadilla's full-sized avatar
🏠
Working from home

Facundo Padilla facundopadilla

🏠
Working from home
View GitHub Profile
@facundopadilla
facundopadilla / main.py
Last active March 14, 2023 20:10
Anti CLRF in Python - Logging module - Log injection
import logging
import sys
import anticrlf
formatter = anticrlf.LogFormatter(
"%(asctime)s - %(name)s - %(levelname)s: Line %(lineno)s | %(message)s" # replace it for another format
)
formatter.replacements["\n"] = "\\x0A" # OPTIONAL: \x0a is a equivalent of \n in bash
@facundopadilla
facundopadilla / jwt_generator.py
Last active March 6, 2023 14:49
Generate RSA private and public key in Python on memory for JWT tokens
from datetime import datetime, timedelta, timezone
from jose import jwt # or import jwt
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend
# --- Generate private and public key ---
key = rsa.generate_private_key(