Skip to content

Instantly share code, notes, and snippets.

View RichardEllicott's full-sized avatar

Richard Ellicott RichardEllicott

  • Luton
View GitHub Profile
@RichardEllicott
RichardEllicott / gist:bb0fc57a90cb949377fc0a211c1c0e87
Last active April 1, 2018 15:13
unusual hashing scheme, not designed for passwords but for sending client ID's publicly in shorter strings, adds random bytes to a truncated sha256
from __future__ import absolute_import, division, print_function
import hashlib
from Crypto import Random
def myhash(data, iv_length=8, hash_length=16):
'''
my hash scheme made to behave somewhat like bcrypt by having an IV
this is randomly generated and attached to the front of the hash, it is also injected into the sha256 hash
this ensures the hash is generated different
the hash is designed to obscure some operating information of my covert software where bcrypt would be the best choice but is too long
@RichardEllicott
RichardEllicott / gist:2f896905e14ec7090e9e476d166095a8
Created April 14, 2018 15:23
very simple RSA example using the pycrypto module
'''
pip install pycrypto
'''
from Crypto.PublicKey import RSA
from Crypto import Random
import ast
@RichardEllicott
RichardEllicott / pq_to_ned.py
Last active May 1, 2018 12:42
calculate n,e,d vars from p and q to create an RSA key
def calculate_rsa_nedpq(p=1090660992520643446103273789680343, q=1162435056374824133712043309728653):
"""
input large primes p and q, returns the 5 components in a tuple (n, e, d, p, q) which can be used to construct private keys like:
RSA.construct()
https://crypto.stackexchange.com/questions/19444/rsa-given-q-p-and-e?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
"""
def egcd(a, b):
x, y, u, v = 0, 1, 1, 0
while a != 0:
from __future__ import absolute_import, division, print_function
from Cryptodome.PublicKey import RSA
from Cryptodome.Random import get_random_bytes
from Cryptodome.Cipher import AES, PKCS1_OAEP
data = "I met aliens in UFO. Here is the map.".encode("utf-8")
recipient_key = RSA.import_key(open("shroomery_encrypt_key_cache/1024.public.pem").read())
session_key = get_random_bytes(16)
import random
s = ''
for n in range(10):
s += random.choice('abc')
print(s)
import sys
filename = sys.argv[1] # first argument
string_to_count = sys.argv[2] # second argument
with open(filename) as f: # opens a file, f becomes the file object, this is the official PEP8 style for reading files
text = f.read() # we need to read the data from that file
print(text.count(string_to_count)) # strings have a special function in python that can count the occurrences of a string within them
if pcall(function ()
print('test1')
error()
end)then
print('test2')
else
print('test3')
end
if pcall(function ()
print('test1')
error()
end)then
print('test2')
else
print('test3')
end
mat3 GetTBN();
vec3 GetBumpedNormal(mat3 tbn, vec2 texcoord);
vec2 ParallaxMap(mat3 tbn);
Material ProcessMaterial()
{
mat3 tbn = GetTBN();
vec2 texCoord = ParallaxMap(tbn);
Material material;
var coll_dict_data1 = [
["player",
"1000000000000000", "0000111111111111"],
["playerbullet",
"0100000000000000", "0000101110111011"],
["playerbulletclash",
"0010000000000000", "0000111111111111"],
["enemy",
"0000100000000000", "1111000011111111"],
["enemybullet",