Skip to content

Instantly share code, notes, and snippets.

@MechMK1
MechMK1 / decrypt.js
Created April 1, 2023 01:53
AES-GCM: Python to JavaScript
// This function "converts" a Uint8Array to a CryptoKey object
// Consider this "Boilerplate" code, that doesn't do anything useful.
function importKey(rawKey) {
return window.crypto.subtle.importKey("raw", rawKey, "AES-GCM", true, ["encrypt", "decrypt"]);
}
// This function takes raw bytes and decodes them to utf-8
function decode(bytes) {
// Even though utf-8 is the default, it's always good to be explicit
return new TextDecoder("utf-8").decode(bytes);
@MechMK1
MechMK1 / bitChecker.c
Created February 19, 2020 13:04
A simple tool to calculate the number of bits differing between the SHA-256 hashes of two strings
/*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the
#!/usr/bin/python3
import csv
if __name__ == '__main__':
with open('file.csv', 'r') as f:
reader = csv.reader(f)
your_list = list(reader)
print(your_list)
#!/usr/bin/python3
import math
if __name__ == '__main__':
a = int(input("a: "));
b = int(input("b: "));
res = pow(a,2) + 2*a + pow(b,2);
#!/bin/bash
# Skript: m122_Scripts/BC2SQL_fast.sh
DBFILE="SIX_Bankenstamm.db"
SRCFILE="SIX_BankenstammCH.csv"
TABLENAME="Bankenstamm"
if ! [ -r "$SRCFILE" ]
then
echo "Could not read $SCRFILE. Exiting..."
@MechMK1
MechMK1 / Memory.cs
Created November 9, 2016 18:03
Memory implemented in C#
using System;
namespace Memory
{
class Program
{
/// <summary>
/// Motives of the pairs
/// </summary>
private static char[] displaySymbols = { '@', '☺', '☻', '●', 'Ⱡ', '♫', '♪', '♦', '♥', '♣', '♠', '♂', '♀', '☼', '█', '▲', '℗', 'Ω' };
@MechMK1
MechMK1 / Max.cs
Last active October 24, 2016 09:32
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Liest 10 Gleitkomma-Zahlen ein und speichert sie in ein Array.
double[] numbers = ReadNumbers(10);
@MechMK1
MechMK1 / SQLTux.sh
Last active October 22, 2016 13:15
#!/bin/bash
# Skript: m122_Scripts/SQLTux.sh
DBFILE=linuxusers.db
PASSWDFILE=/etc/passwd
TABLENAME="LinuxBenutzer"
#Stop if the password file is not readable
if ! [ -r "$PASSWDFILE" ]
then
public void WriteLog(string message,
Severity severity = Logger.Defaults.Severity,
Encoding = Logger.Defaults.Encoding,
Color = Logger.Defaults.Color)
{
/*Write your log here*/
}
public void Main()
{
public void WriteLog(string message)
{
WriteLog(message, Logger.Defaults.Severity, Logger.Defaults.Encoding, Logger.Defaults.Color);
}
public void WriteLog(string message, Severity severity)
{
WriteLog(message, severity, Logger.Defaults.Encoding, Logger.Defaults.Color);
}