added hex encoding functions