Skip to content

Instantly share code, notes, and snippets.

@handol
handol / easy_aes.py
Created April 20, 2016 20:52 — forked from twkang/easy_aes.py
Python: Simple AES with zlib
#!/data/local/bin/python
# AES encryption/decryption with zlib compression
from Crypto.Cipher import AES
from Crypto import Random
import hashlib
import zlib
import base64
_block_size = 16
@handol
handol / ssh_socks5.py
Created April 20, 2016 20:52 — forked from twkang/ssh_socks5.py
ssh connection to server behind socks5 proxy : using socksipy(https://code.google.com/p/socksipy-branch/) and paramiko(https://github.com/paramiko/paramiko)
import time
import socket
import paramiko
import socks
SOCKS5_HOST = "nnn.nnn.nnn.nnn"
SOCKS5_PORT = 12345
SERVER_IP = "nnn.nnn.nnn.nnn"
SERVER_PORT = 54321
@handol
handol / m2crypto_aes.py
Created April 20, 2016 20:52 — forked from twkang/m2crypto_aes.py
AES encryption example using M2Crypto module
import sys
import base64
from M2Crypto import Rand, EVP
ENC_METHOD="aes_256_cbc"
MODE_B64, MODE_BIN = 0, 1
IV_LEN = 16
def encrypt(s, key, mode=MODE_BIN):
iv = Rand.rand_bytes(IV_LEN) # can be : iv = os.urandom(IV_LEN)
@handol
handol / read_cert.py
Created April 20, 2016 20:29 — forked from twkang/read_cert.py
파이썬으로 공인인증서 파일 읽기 (추가 설치 모듈: cryptography, pyasn1)
import os
import getpass
from pyasn1.codec.der import decoder as der_decoder
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import padding, hashes
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.asymmetric import padding as asympad
from cryptography.hazmat.primitives.serialization import load_der_private_key