first pass at porting Rails' MessageEncryptor