Skip to content

Instantly share code, notes, and snippets.

@wowkin2
wowkin2 / aes_encryption.py
Created May 7, 2018 14:59
AES encoding sample
import base64
from Crypto.Cipher import AES
class AESCipher(object):
BS = 16
def __init__(self, key):
self.key = key
@wowkin2
wowkin2 / aes_example_in_python.py
Created May 4, 2018 14:29 — forked from dokenzy/aes_example_in_python.py
AES Encrytion Example in Python
#-*- coding: utf-8 -*-
# Python 3.4
# author: http://blog.dokenzy.com/
# date: 2015. 4. 8
# References
# http://www.imcore.net/encrypt-decrypt-aes256-c-objective-ios-iphone-ipad-php-java-android-perl-javascript/
# http://stackoverflow.com/questions/12562021/aes-decryption-padding-with-pkcs5-python
# http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256
@wowkin2
wowkin2 / client.py
Last active April 23, 2018 14:01
Solution to benchmark blocking and non-blocking http-requests using aiohttp session, requests and requests in async executor.
import time
import asyncio
import concurrent.futures
import requests
URL_SESSION = 'http://localhost:8061/session'
URL_REQUESTS = 'http://localhost:8061/requests'
URL_REQUESTS_EXECUTOR = 'http://localhost:8061/requests_executor'
@wowkin2
wowkin2 / Email Server (Windows Only).md
Created January 17, 2018 12:13 — forked from raelgc/Email Server (Windows Only).md
Setup a Local Only Email Server (Windows Only)
@wowkin2
wowkin2 / gist:dc30a3f12abc77f2afc750fbe3464d3b
Created August 18, 2017 13:49 — forked from rchrd2/gist:6179550
How to link django-social-auth with google-api-python-client I am creating a gist, because this took me way to long to figure out. Maybe it can save you some time!
import httplib2
from apiclient.discovery import build
from oauth2client.client import AccessTokenCredentials
def connect_helper(user):
c = user.social_auth.get(provider='google-oauth2')
access_token = c.tokens['access_token']
credentials = AccessTokenCredentials(access_token, 'my-user-agent/1.0')
http = httplib2.Http()
@wowkin2
wowkin2 / blockchain.py
Last active May 18, 2018 09:13
Simple implementation of blockchain by example
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import hashlib as hasher
import datetime as date
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
@wowkin2
wowkin2 / attack.md
Created January 17, 2017 21:21 — forked from timruffles/attack.md
Chrome/Gmail attack received 11/03/2016. Not sure if the Chrome meta refresh + data:text,html technique is novel.

The following attack will display a "you've been signed out" page for GMail, and attempt to steal your account credentials.

DO NOT PUT ANY ACCOUNT CREDENTIALS INTO ANY TABS CREATED AFTER VISITING THESE LINKS :)

I received an email in my GMail inbox with a fake attachment image, styled to look like the real GMail attachment UI:

fake

This linked to a page that ended up displaying a fake "you've been signed out" link, via the data:text/html... URL feature of Chrome:

@wowkin2
wowkin2 / autofixtures_to_human_readable.py
Last active December 9, 2016 10:09
Update django username after AutoFixture to human readable format using Faker
"""
To update users to human-readable form
"""
from django.contrib.auth.models import User
from faker import Faker
def update_users():
@wowkin2
wowkin2 / gist:8b7f43a4f2b5c6957cf51be60a7b8268
Created November 29, 2016 14:34 — forked from signed0/gist:2031157
Google Polyline encoder & decoder
'''Provides utility functions for encoding and decoding linestrings using the
Google encoded polyline algorithm.
'''
def encode_coords(coords):
'''Encodes a polyline using Google's polyline algorithm
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html
for more information.
@wowkin2
wowkin2 / get-browser-locale.js
Created August 23, 2016 12:57 — forked from asleepwalker/get-browser-locale.js
Boilerplate browser locale detector
function getLocale() {
var lang;
if (navigator.languages) {
// chrome does not currently set navigator.language correctly https://code.google.com/p/chromium/issues/detail?id=101138
// but it does set the first element of navigator.languages correctly
lang = navigator.languages[0];
} else if (navigator.userLanguage) {
// IE only
lang = navigator.userLanguage;