Fix the hexencode function