How to generate a Base36 quick code sequence using the SHA2 hash

On a 'slowish' 2GHz machine it can generate 20,000 quickcodes per minute. The spread of the resulting quickcodes is near-perfectly even, which means that substrings of the quickcode can be used to construct a hashed directory tree for holding, for example, the huge amount of product image files associated with a product catalog. Using a hashed directory tree is a quick and efficient method to host millions of separate files for quick, random access, as most file systems only perform optimally with less than 1,000 contained in a directory

This deterministic techique uses a hash of the sequential Integer Id of an item to generate a typical product quickcode for it, as found in many shopping catalogues. Example of how a quickcode is generated from its primary key integer Id:

  • 1 => 8M9LFLN2
  • 2 => HZ40H3K0
  • 3 => 02LUJYQ2
  • etc..

You can download the Base36 Quickcode Generator test script, which demonstrates an implementation in Perl and MySQL.

SuDoku Perl Package

Download the Perl package here

A popular Christmas la-di-da rewritten in the Perl programming language. What makes this different to other poems is that it actually produces useful output, although only if you run this poem at night. In case you don't speak fluent Perl (most people will soon discover that do they speak some), the original verse is shown below. 

A simple fortune-cookie program. Fortune cookie files tend to be in a universal format and can be downloaded from many sources. Put them in a directory such /usr/share/fortune.