Skip to content

Instantly share code, notes, and snippets.

View trcio's full-sized avatar

patricio trcio

  • Texas
  • 05:31 (UTC -05:00)
View GitHub Profile
function getKey(identifier) {
var chars = '0123456789ABCDEFGHJKLMNPQRTUVWXY',
hash = CryptoJS.MD5(identifier).toString().toUpperCase(),
parts = [];
for (var i = 0; i < 32; i += 2) {
var nextDigit = parseInt(hash.substr(i, 2), 16) & 31,
withDash = (((i % 8) == 0) && (i > 0));
parts.push(withDash ? '-' : '');
@trcio
trcio / MbamGen.php
Last active August 29, 2015 14:12
CREDITS GO TO MR TRVP
<?php
class MbamGen {
public function get_key() {
$data = [
'id' => $this->random_char() . $this->random_char() . $this->random_char() . $this->random_char() . $this->random_char(),
'key' => ''
];
$hash = strtoupper(md5($data['id']));
@trcio
trcio / GAuthProvider.cs
Last active September 23, 2017 17:26
A small, lightweight class to create codes for use with the Google Authenticator app
using System;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
namespace GAuthWrapper
{
public static class GAuthProvider
{
public static int CodeLength { get; set; }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Xml.Serialization;
using Org.BouncyCastle.Asn1.Sec;
namespace BitcoinTools
@trcio
trcio / UserPrefs.cs
Last active August 29, 2015 14:08
Stores and accesses user preferences between sessions. Based off of Unity's PlayerPrefs class: http://docs.unity3d.com/ScriptReference/PlayerPrefs.html
using System;
using System.Reflection;
using Microsoft.Win32;
/// <summary>
/// Stores and accesses user preferences between sessions.
/// </summary>
public static class UserPrefs
{
private static readonly RegistryKey MainKey;
@trcio
trcio / ConsoleMenu.cs
Last active August 29, 2015 14:07
Easy way to implement menu's into your console program
using System;
using System.Collections.Generic;
namespace ConsoleMenu
{
public class ConsoleMenu
{
private readonly List<MenuOption> Options;
public delegate void ConsoleMenuOptionSelectedEventHandler(ConsoleMenuOptionSelectedEventArgs e);
@trcio
trcio / PasteSxProvider.cs
Created September 1, 2014 04:53
A fully-featured paste.sx API wrapper.
using System;
using System.Collections.Specialized;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
namespace PasteSx
{
@trcio
trcio / Aes.cs
Last active August 29, 2015 14:05
Simple AES wrapper
using System.Security.Cryptography;
public static class Aes
{
public static byte[] Encrypt(byte[] data, byte[] key)
{
if (data == null)
throw new ArgumentNullException("data");
if (key == null)
throw new ArgumentNullException("key");
@trcio
trcio / PCompiler.cs
Created August 17, 2014 06:54
Small, easy CodeDom wrapper
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Resources;
using System.Text;
using Microsoft.CSharp;
using Microsoft.VisualBasic;
namespace PCompile
{
Imports System.Runtime.Serialization.Json
Imports System.IO
Imports System.Text
Public Class JsonUtil
''' <summary>
''' Serializes an object to the respectable JSON string.
''' </summary>
Public Shared Function Serialize(Of T)(o As T) As String
Dim s = New DataContractJsonSerializer(GetType(T))