Skip to content

Instantly share code, notes, and snippets.

View luk0y's full-sized avatar
🎯
Focusing

luk0y luk0y

🎯
Focusing
View GitHub Profile
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
Goa
Gujarat
Haryana
Himachal Pradesh
Jammu and Kashmir
@luk0y
luk0y / gen-rsa-pubkey.sh
Created November 10, 2020 06:23 — forked from icetan/gen-rsa-pubkey.sh
Create a public RSA key from modulus and exponent on the command line
#!/bin/bash
set -e
b2hex() { echo -n $1|base64 --decode | xxd -p -u | tr -d \\n; }
modulus=$(b2hex u2/nlDLMbqLY+XBnWlqHv74a/wvmPoefKv+5NkTU0sbQAEMN7Gar9Hgp50uMUQhiOhwO6L4hezrY021etPyh2Q==)
exponent=$(b2hex AQAB)
asn1conf=$(echo -e "asn1=SEQUENCE:pubkeyinfo\n[pubkeyinfo]\nalgorithm=SEQUENCE:rsa_alg\npubkey=BITWRAP,SEQUENCE:rsapubkey\n[rsa_alg]\nalgorithm=OID:rsaEncryption\nparameter=NULL\n[rsapubkey]\nn=INTEGER:0x$modulus\ne=INTEGER:0x$exponent" | openssl asn1parse -genconf /dev/stdin -noout -out /dev/stdout | base64)
@benwattsjones
benwattsjones / gmail_mbox_parser.py
Last active May 28, 2024 15:16
Quick python code to parse mbox files, specifically those used by GMail. Extracts sender, date, plain text contents etc., ignores base64 attachments.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
import mailbox
import bs4
def get_html_text(html):
try:
return bs4.BeautifulSoup(html, 'lxml').body.get_text(' ', strip=True)
except AttributeError: # message contents empty