python

Splay tree data structure implementation

In 1985 Sleator & Tarjan developed the self-adjusting Splay tree data structure. It is a binary search tree which implicitly reorders and readjusts itself by the use of so called splay operations. Regular operations such as insert, delete, lookup, min, max etc. all take amortized time O(log n), where n is the amount of nodes in the tree. The Splay tree is most efficient when a sequence of operations are carried at which point it rivals other binary search trees.

Exploiting MD5 collisions

In 1996 it was discovered that the MD5 hash-algorithm had problems. Furthermore, an algorithm was devised to generate these collisions in 2005.

Implementation of SHA 1, 256, 384, and 512

As a continuation of the previous entry about the implementation of SHA-1, I've now implemented the last three algorithms as well. These are SHA-256, SHA-384, and SHA-512. SHA-1 provided a 160-bit digest, SHA-256 provides a 256-bit digest, SHA-384 provides a 384-bit digest, and, believe it or not, SHA-512 provides a 512-bit digest. These algorithms are described in FIPS 180-2.

The usage is the same as for SHA-1, except for a little detail of specifying the exact algorithm to use:

>>> import sha

Implementation of the Secure Hash Algorithm (SHA) 1

As a bit of fun I implemented the Secure Hash Algorithm (SHA) 1 late last night. It was done using Python3 and accordingly to FIPS 180-1.

Below is shown how to use it:

>>> import sha1
>>> data = sha1.str2bin("All your base are belong to us!")
>>> sha1.digest(data)
'1110101011101101100000101101000101010000110001110110110010000011
 1101011101110100101001110011011101001110011110001100111000000111
 11010001110010001100100010100110'
>>> sha1.hex_digest(data)
Syndicate content