Skip to content

Instantly share code, notes, and snippets.

View mllnd's full-sized avatar

Markkus Millend mllnd

View GitHub Profile
@mllnd
mllnd / gen_secret.py
Created November 11, 2019 11:09
Django Create Secret Key
from django.core.management.utils import get_random_secret_key
get_random_secret_key()
@mllnd
mllnd / overlay.py
Created May 6, 2019 16:38
Python Flag Overlays
from PIL import Image, ImageDraw
# The RGBA opacity for flag stripes
# 0 is the lowest opacity, 255 highest (no opacity at all)
rgba_opacity = 155
overlays = {
"EST": {
"orientation": "horizontal",
"colors": [
@mllnd
mllnd / 3des.php
Created March 6, 2019 17:08
PHP 3DES (Triple DES) Encryption
<?php
$text = 'Super awesome string that goes through encryption';
$secret = 'D05XC051X1KLRWQ8';
$encrypted = encrypt($text, $secret);
echo "Encrypted value: $encrypted\n";
$decrypted = decrypt($encrypted, $secret);
echo "Decrypted value: $decrypted\n";
@mllnd
mllnd / cbc.php
Created March 6, 2019 17:00
PHP CBC (Cypher Block Chaining) Encryption
<?php
define('AES_256_CBC', 'aes-256-cbc');
$data = "The string that will be encrypted/decrypted";
$encryption_key = openssl_random_pseudo_bytes(16); // 32 bytes can also be used
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length(AES_256_CBC));
$encrypted = openssl_encrypt($data, AES_256_CBC, $encryption_key, 0, $iv);
echo "Encrypted: $encrypted\n";
@mllnd
mllnd / vigenere.php
Created March 6, 2019 16:54
PHP Vigenére Cipher
<?php
$text = 'String that will be encrypted';
$password = 'SuperSecretPassword';
$encrypted = encrypt($password, $text);
echo "Encrypted text: $encrypted\n";
$decrypted = decrypt($password, $encrypted);
echo "Decrypted text: $decrypted\n";
function encrypt($pswd, $text) {
@mllnd
mllnd / otp.php
Created March 6, 2019 16:51
PHP One-Time Pad Encryption
<?php
$encrypted = encryptDecrypt('wiki');
echo "Encrypted: $encrypted\n";
$decrypted = encryptDecrypt($encrypted);
echo "Decrypted: $decrypted\n";
function encryptDecrypt($input) {
$key = 'C';
$output = '';
for ($i = 0; $i < strlen($input); $i++) {
@mllnd
mllnd / bubblesort.c
Last active September 9, 2019 12:06
Bubble Sort for ICS0017
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
int* Bubble(int length, int* array) {
// Allocate new array and clone it
size_t copy_size = sizeof(int) * length;
int *array_copy = malloc(copy_size);
memcpy(array_copy, array, copy_size);