(MySQL) Age in Years for Given Birthdate

Given a birthdate in @dob, here are two simple formulae for age in years :
(the second formulae is for age in years to two decimal places, ignoring day of month)

Read More »

→ Continue Reading

(JavaScript) Generic List in Javascript

The closest to a generic List in javascript.
When calling constructor – new List(Module) – add model in constructor parameter

Read More »

→ Continue Reading

(JavaScript) Google Maps API V3 Javascript Full Example

This javascript will create a complex google javascript map with multiple locations selected marked. The map will be centered in the middle and zoomed so that all point can be seen. It also stylizes the map making it mostly desaturated with bits of orange. More explanation as to how to set this up and change it at the url.

Read More »

→ Continue Reading

(PHP) Fibonacci series (several different algorithms)

Planning to add proper PHPunit and PHPlogger code examples and blog about it at http://bcmoney-mobiletv.com/blog/

Read More »

→ Continue Reading

(Bash) Check if a file exists

 

Read More »

→ Continue Reading

(Bash) Check if a folder exists

 

Read More »

→ Continue Reading

(Bash) How to check the superuser privileges

 

Read More »

→ Continue Reading

(Python) Simple XOR Hash

This is a simple hash that pads its input to the block size and XORs every block together. Output is in hexadecimal octets.

Read More »

→ Continue Reading

(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 state space is a parameter–the size of the key must not exceed the size of the state space.

Read More »

→ Continue Reading

(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 (TODO: change this). Reports a hash of the encrypted chunk for storage/retrieval without needing to calculate HMAC until decryption.

Needs a lot of cleanup and some fixes. Makes a lot of assumptions, for instance, that current_block, total_blocks, and data_size only occupy 1 byte apiece. Currently doesn’t strip padding after decoding, and doesn’t convert original integers for current_block, total_blocks, and data_size back from bytes.

Read More »

→ Continue Reading