01st June, 2017

Generating inverted indexes in Python

Generating inverted indexes from text files in Python 3.6.

You can find this project on my GitHub by clicking here.


This program constructs an inverted index from the words contained within a series of text files; the index is generated in memory and them saved to disk immediately. The index is constructed in a way where all files associated with a word are contained within a single text file; in other words, each word has its own text file - each text file contains a JSON string object, which contains a list of objects, which each contain which file contained the word and how many times the word occurred.

Word file structure

The word "hello" found in fi...

Read more

01st May, 2017

Hiding messages inside images in Python

A program that takes messages and stores them using the pixels of an image, written in Python 3.5.

This program takes text messages and stores them inside images by manipulating the RGB channels of pixels. You can find this project on my GitHub by clicking here.

Most colour images use 24 bit RGB to store and display the colour values for every pixel - each pixel has three 8 bit channels (one for red, one for blue, and one for green) meaning each channel is capable of representing a value between 0 and 255, and each individual pixel has a total of 24 bits. If we converted a 24 bit pixel to denary we would see a value like 255, 255...

Read more

15th April, 2017

Selection sort in Python

A selection sort algorithm in Python 3.5.

This is a simple script that sorts lists (of arbitrary lengths) of unsorted numbers from lowest to highest. https://en.wikipedia.org/wiki/Selection_sort.

Selection sort is a very simple sorting algorithm that works by iterating over all elements in an unsorted list and finding the smallest value for each iteration - the smallest value is then pushed to the beginning of the list. This process continues until all elements have been selected and moved to their correct position at the beginning of the list. Sorting elements in this way means all elements are sorted in order - the smallest elements are sorted first, and largest elements are sorted last.

The worst-case performance and complexity of t...

Read more

13th April, 2017

Bubble sort in Python

A bubble sort algorithm in Python 3.5.

This is a simple script that sorts lists (of arbitrary lengths) of unsorted numbers from lowest to highest. https://en.wikipedia.org/wiki/Bubble_sort.

Bubble sort is a very simple sorting algorithm that works by iterating over all elements in an unsorted list and comparing the current element to the element to its immediate right - if the element to the right is greater than the current element, swap both elements. This process continues until no more swaps occur - meaning all elements must be sorted. Sorting numbers in this way causes the largest numbers to be sorted first; bubble sort causes the largest numbers to all “bubble” up the top of the list - which is where the name comes from.

The wors...

Read more

20th March, 2017

ROT13 web proxy

A web proxy that uses ROT13 to cipher data.

wsantos.io/p is a web proxy that remotely fetches web pages and uses ROT13 to cipher text during transit - evading HTTP/HTTPS packet inspection since the text is obfuscated.

This web proxy works by remotely fetching web pages from the URL entered into the text box; the URL is sent to the web server via AJAX encapsulated in a JSON object. Once the remote server has fetched the web page data, any character from a-z (the key is alphabetical only, so less data needs to be ciphered - improving performance) is ciphered using this ROT13 algorithm. The ciphered web page data is then sent back to the client via AJAX, encapsulated in another JSON object; the client ...

Read more

25th February, 2017

Rail fence ciphering in Python

A rail fence algorithm in Python 3.5.

This is a Python 3.5 script for ciphering strings using rail fence cipher.
https://en.wikipedia.org/wiki/Rail_fence_cipher. You can find this project on my GitHub by clicking here.

This is a Python function that uses multidimensional arrays to create a matrix at X length (the length of the string) and Y depth (the key specified) to encipher and decipher data using rail fence - a method for arranging data in a zig-zag pattern using a grid.

Rail fence doesn't require a symmetric key in the same way ROT13 does; rail fence has a...

Read more

24th February, 2017

ROT13 in Python

A simple ROT13 algorithm in Python 3.5.

This is a Python 3.5 script for ciphering strings using ROT.
https://en.wikipedia.org/wiki/ROT13, https://en.wikipedia.org/wiki/Caesar_cipher. You can find this project on my GitHub by clicking here.

This is a simple plug-and-play ROT function. Simply pass the cipher function a string, key, shift value, and mode (1 for encipher, and -1 for decipher) and the function will return a enciphered / deciphered string.
It is possible to use any key and any shift value with this f...

Read more