I am trying to figure out how to work with byte sequences by decoding a hex string to a byte sequence, my goal is to encode that decoded byte sequence to a base64 string .
The ocaml manual doesn’t give clues about this (Bytes module docs) and the mirage-base64 library takes string as inputs which is weird given it’s an explicit bytes to ascii encoding.
For example in python I would do the following :
import binascii input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d" as_bytes = binascii.unhexlify(input) got = binascii.b2a_base64(as_bytes) b'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t\n' got.decode("utf-8") 'SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t'
This is taken from the cryptopals challenge .