Skip to content

Instantly share code, notes, and snippets.

/**
* $RCSfile$
* $Revision: 3657 $
* $Date: 2002-09-09 08:31:31 -0700 (Mon, 09 Sep 2002) $
*
* Adapted from Markus Hahn's Blowfish package so that all functionality is
* in a single source file. Please visit the following URL for his excellent
* package: http://www.hotpixel.net/software.html
*
* Copyright (c) 1997-2002 Markus Hahn <markus_hahn@gmx.net>
#!/bin/bash
# Color shortcuts
co_black='\[\e[30m\]'
co_red='\[\e[31m\]'
co_green='\[\e[32m\]'
co_yellow='\[\e[33m\]'
co_blue='\[\e[34m\]'
co_purple='\[\e[35m\]'
co_cyan='\[\e[36m\]'
co_white='\[\e[37m\]'
@Ivoz
Ivoz / calldules.py
Last active October 19, 2020 11:17
import ctypes
# Create a function prototype for a 3-arg function
ternaryfunc = ctypes.CFUNCTYPE(ctypes.py_object, ctypes.py_object,
ctypes.py_object, ctypes.c_void_p)
# Define a new python type that's callable, via a ternaryfunc
class PyTypeObject(ctypes.Structure):
@Ivoz
Ivoz / AddPythonToPath.py
Created July 20, 2020 04:49
If you are able to run python code, use this to add python to your path on windows
import sys
from pathlib import Path
# Get the path to the Scripts directory
scripts_path = Path(sys.base_prefix) / "Tools" / "Scripts"
# Append it to python's import path so we can grab it
sys.path.append(str(scripts_path))
# Import the main function from the win_add2path script
from win_add2path import main
# run the main function to add python to out path
@Ivoz
Ivoz / dlp.py
Last active December 25, 2017 01:55
Naive way to solve the Discrete Logarithm Problem
#!/usr/bin/env python
from __future__ import print_function
def find_discrete_log(h, g, p):
H = {}
print('Generating table...')
for x1 in range(0, B):
gx1inv = mod_mul_inv(pow(g, x1, p), p)
H[(h * gx1inv) % p] = x1
@Ivoz
Ivoz / quine.py
Last active January 31, 2016 18:10
A self-checking python quine, of sorts
#!/usr/bin/env python3
'''
A "self-verifying" quine - `<quine> <source_file>` will only print itself
if `<quine>` has the same output as `cat <source_file>`
'''
source = r'''{foreword}
import sys, subprocess
if len(sys.argv) > 1:
@Ivoz
Ivoz / rstlinks.md
Last active January 3, 2016 10:48
How to replicate labelled linking with rst?
@Ivoz
Ivoz / gist:7035239
Last active December 25, 2015 20:29
from __future__ import absolute_import, division, print_function
from cryptography.bindings import _default_api
class BlockCipher(object):
def __init__(self, cipher, mode, api=None):
super(BlockCipher, self).__init__()
if api is None:
@Ivoz
Ivoz / .gitignore
Last active December 25, 2015 19:29
_site/
bower_components/
.sass_cache/
.ruby-version
@Ivoz
Ivoz / fixpos.py
Created September 23, 2013 19:15
import os
import sys
from os.path import join
from fabric.api import local
BASE_DIR = os.path.realpath(os.path.dirname(__file__))
BUILD_DIR = join(BASE_DIR, '_build')
SOURCE_DIR = join(BASE_DIR, 'source')
LOCALE_DIR = join(SOURCE_DIR, 'locale',