Tag Archives: programming

(Python) ARC4

This is a pure Python implementation of raw ARC4, sans any improvements. For instance, it could take a nonce, use multiple state spaces (parallelizable), automatically discard the first 4K of the state space(s), use a more complex transformation than a simple swap, limit the # of bytes encrypted per nonce, etc.. The size of the [...]

Posted in Python | Also tagged , , , , , | Leave a comment

(Python) All-Or-Nothing Transform

Performs an all-or-nothing transform on a stream of chunks. The data can only be decrypted if every block is present to generate an HMAC for. The list of HMACs is then XOR’d against the final block from the transform, yielding the decryption key for the blocks. Currently uses the HMAC key for encryption as well [...]

Posted in Python | Also tagged , , , , , , | Leave a comment

(Python) HMAC

HMAC, pass a hash from Crypto.Hash in PyCrypto. Key should be a bytes object. Returns a bytearray.

Posted in Python | Also tagged , , , , | Leave a comment

(Python) Chunk Data for Streaming

Chunks data into block_size blocks for streaming, adds null padding.

Posted in Python | Also tagged , , , | Leave a comment

(Java) Quicksort in Java, with Enforced Suckitude

It’s no fun implementing QuickSort unless you can force it out of its blister-fast, O(n log n) speed and humiliate it with its worst-case, O(n^2) runtime. So that’s what I set out to do. My naive partition simply pivots around the low item, but my randomized partition defeats the sucky inputs by choosing a random [...]

Posted in Java | Also tagged , , , , , | Leave a comment

(PHP) auto complete like google suggestion

auto complete code snippet like google suggestions

Posted in JavaScript, PHP | Also tagged , , , , , , | Leave a comment

Hooking with the Microsoft Detours library in C++

The DLL Injection example described how to inject a DLL into an existing process. The snippets below demonstrate a combination of hooking and DLL injection in C++ with the Microsoft Detours library. Quote: In computer programming, the term hooking covers a range of techniques used to alter or augment the behavior of an operating system, [...]

Posted in C++ | Also tagged , , , , , , , , , , , , , , , | Leave a comment

Assembling with nasm and disassembling with ndisasm

The following commands demonstrate assembling with nasm and disassembling with ndisasm. $ cat example.s mov eax,0 test eax,eax $ nasm example.s $ ndisasm example 00000000 66B800000000 mov eax,0×0 00000006 6685C0 test eax,eax The first column of the disassembly contains the file offset, the second column contains the opcodes and the third contains the assembly instructions. [...]

Posted in Assembler, Bash | Also tagged , , , , , | Leave a comment

(C++) Gaussian Elimination

Numerical Methods application for solving system of equation using Gaussian Elimination based on this Wikipedia article: http://en.wikipedia.org/wiki/Gaussian_elimination

Posted in C++ | Also tagged , , , , , , , | Leave a comment

(C#) Pull Image into Byte Array from a URL

This snippet pulls down an image from a URL into a byte[]. From there you can re-size or save. Don’t forget the necessary try – catch.

Posted in C# | Also tagged , , , , , , , | Leave a comment