AES encryption with Java

Mar 20, 2018 - 3 minutes

The following code is for encrypting short messages (it acts on byte arrays and not streams so the whole message needs to fit in memory). It creates a random Initialisation Vector (IV) for each message which is prepended to the start of the encrypted stream.

Read more ...

Minimal logging configuration with Java, SLF4J & Gradle

Mar 9, 2018 - 1 minutes

This is mainly here for my copying and pasting for a new Java project.

The gradle deps bring the SLF4J API in to the compile time classpath and the LOG4J implementation in to the runtime. If you wanted to compile the log4j implementation in to your code base (e.g. building an application and not a library), you would need to move it into the compile list.

Read more ...

GPG With Multiple Recipients

Mar 22, 2015 - 3 minutes

This is how to store sensitive information (e.g. SSL key passphrases) in a GPG encrypted file with multiple recipients. If you’re using git to store the file (which you probably should be), always do a git pull before doing any changes. These files are binary and therefore merges are very difficult otherwise.

Read more ...

Encode Base36 in Python

Feb 1, 2015 - 1 minutes

The cleanest way I’ve found so far to encode/decode between base36 and integers in Python. The primary purpose of this was to write a url shortener based on looking up a numbered url from a database.

Read more ...