Skip to content

Instantly share code, notes, and snippets.

View AdamWhiteHat's full-sized avatar
🏠
Working from home

Adam White AdamWhiteHat

🏠
Working from home
View GitHub Profile
@AdamWhiteHat
AdamWhiteHat / HashCodeHelper.cs
Last active December 22, 2020 10:28
Combine two hashcodes
public static class HashCodeHelper
{
public static int Combine(int h1, int h2)
{
uint num = (uint)((h1 << 5) | (int)((uint)h1 >> 27));
return ((int)num + h1) ^ h2;
}
}
@AdamWhiteHat
AdamWhiteHat / Eratosthenes.cs
Last active December 22, 2020 10:28
Sieve of Eratosthenes.
public static class Eratosthenes
{
public static IEnumerable<BigInteger> Sieve(Int64 maxValue)
{
if (maxValue < 10)
{
if (maxValue == 9 || maxValue == 8 || maxValue == 7)
{
return new List<BigInteger>() { 2, 3, 5, 7 };
}
@AdamWhiteHat
AdamWhiteHat / prime-sieve.svg
Created December 22, 2016 21:21
Javascript in SVG example (prime circles)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tuxxy
tuxxy / homomorphic_rsa_demo.py
Last active October 31, 2019 03:16
This is a demo of the multiplicative homomorphic qualities of unpadded RSA encryption.
#!/usr/bin/env python3
from Cryptodome.PublicKey import RSA
# A proof of concept demo showing the multiplicative limited
# homomorphic qualities of unpadded RSA
# (Unpadded RSA is not secure by modern standards)
def gen_key(size):
key = RSA.generate(size)