Encodes binary data to a string using the specified format.
The binary data to encode
The encoding format ('base64' or 'hex')
The encoded string
Encodes binary data to a string using the specified format.