Crypto refactor

Add HMAC-SHA256 and use common format for encoding and crypto

Fixes #47