Skip to content

Instantly share code, notes, and snippets.

@hasherezade
hasherezade / aes_crypt.cpp
Last active March 6, 2024 02:32
AES 128 - encrypt/decrypt using Windows Crypto API
#include <Windows.h>
#include <wincrypt.h>
#include <stdio.h>
#pragma comment(lib, "advapi32.lib")
#define AES_KEY_SIZE 16
#define IN_CHUNK_SIZE (AES_KEY_SIZE * 10) // a buffer must be a multiple of the key size
#define OUT_CHUNK_SIZE (IN_CHUNK_SIZE * 2) // an output buffer (for encryption) must be twice as big
//params: <input file> <output file> <is decrypt mode> <key>
@caspencer
caspencer / OpenSslCompatDeriveBytes.cs
Created November 4, 2011 16:12
Derives a key from a password using an OpenSSL-compatible version of the PBKDF1 algorithm.
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
namespace OpenSslCompat
{
/// <summary>
/// Derives a key from a password using an OpenSSL-compatible version of the PBKDF1 algorithm.
/// </summary>
@Neo23x0
Neo23x0 / nmap-cmdline
Last active March 19, 2020 17:10
Nmap Scan Params for CVE-2017-0143 MS17-010 Scanning
# Scan for CVE-2017-0143 MS17-010
# The vulnerability used by WannaCry Ransomware
#
# 1. Use @calderpwn's script
# http://seclists.org/nmap-dev/2017/q2/79
#
# 2. Save it to Nmap NSE script directory
# Linux - /usr/share/nmap/scripts/ or /usr/local/share/nmap/scripts/
# OSX - /opt/local/share/nmap/scripts/
#
@bitbeans
bitbeans / Pkcs7.cs
Last active July 19, 2019 20:29
PKCS7 padding in C#
/// <summary>
/// Removes the Pkcs7 padding of an array.
/// </summary>
/// <param name="paddedByteArray">The padded array.</param>
/// <returns>The unpadded array.</returns>
/// <exception cref="OverflowException"></exception>
/// <exception cref="ArgumentOutOfRangeException"></exception>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentNullException"></exception>
public static byte[] RemovePkcs7Padding(byte[] paddedByteArray)
@natmchugh
natmchugh / sha1.php
Last active August 10, 2018 15:08
Pure PHP implementation of SHA1from wikipedia pseudo code
<?php
/*
Note 1: All variables are unsigned 32 bits and wrap modulo 232 when calculating, except
ml the message length which is 64 bits, and
hh the message digest which is 160 bits.
Note 2: All constants in this pseudo code are in big endian.
Within each word, the most significant byte is stored in the leftmost byte position
*/