encode/decode for hash strings