Skip to content

Instantly share code, notes, and snippets.

View jimbojetset's full-sized avatar

Jim Booth jimbojetset

  • UK
View GitHub Profile
using System;
using System.Runtime.InteropServices;
namespace TranslucentTB
{
class Program
{
[DllImport("user32.dll")]
internal static extern IntPtr SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
[DllImport("user32.dll")]
@jimbojetset
jimbojetset / EnigmaMachine.cs
Created January 10, 2017 20:20
Enigma Emulator c#
using System;
using System.Text;
using System.Diagnostics;
namespace Enigma
{
class EnigmaMachine
{
private const string _alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
private static Tuple<string, int, int> _rotor_Blank = new Tuple<string, int, int>("ABCDEFGHIJKLMNOPQRSTUVWXYZ", -99, -99);
def make_pi(l):
q, r, t, k, m, x, j = 1, 0, 1, 1, 3, 3, 0
while j < l + 2:
if 4 * q + r - t < m * t:
yield m
j += 1
q, r, t, k, m, x = 10*q, 10*(r-m*t), t, k, (10*(3*q+r))//t - 10*m, x
else:
q, r, t, k, m, x = q*k, (2*q+r)*x, t*x, k+1, (q*(7*k+2)+r*x)//(t*x), x+2
#!/usr/bin/python3.5
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015 James Booth
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Copyright (c) 2015 James Booth
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
@jimbojetset
jimbojetset / Totp.cs
Last active November 2, 2022 04:03
A very simple and basic TOTP (Google) Authenticator Class in c#
// Compatible with .Net Framework V2 and above
// Base32 code adapted from http://stackoverflow.com/questions/641361/base32-decoding
// Usage::
// From the url otpauth://totp/Google%3A{YOUR-EMAIL}?secret={YOUR-SECRET}&issuer=Google
// string base32secret = "{YOUR-SECRET}";
// string pin = Totp.GeneratePin(base32secret, 30, 6);
using System;
using System.Globalization;
using System.Security.Cryptography;