(* hex to raw bytes *)
let rec hex_to_raw hexstring =
let rec hexraw hexstr rawstr =
let tophex
= String.sub hexstr
0 2 in let newrawstr
= rawstr
^ (Char.chr topint
) in let remlen
= (String.length hexstr
) - 2 in let newhexraw
= String.sub
2 remlen
in if remlen == 0 then newrawstr
else hexraw newhexraw newrawstr
hexraw hexstring "" ;;
hex_to_raw "badf00d"
let b64_to_raw b64string =
rawstring ;;
let raw_to_hex rawstring =
rawstring ;;
let raw_to_b64 rawstring =
rawstring ;;
Printf.printf
"%s" (raw_to_b64
(hex_to_raw
"badf00d"))
KCogaGV4IHRvIHJhdyBieXRlcyAqKQpsZXQgcmVjIGhleF90b19yYXcgaGV4c3RyaW5nID0gCiAgbGV0IHJlYyBoZXhyYXcgaGV4c3RyIHJhd3N0ciA9IAogICAgbGV0IHRvcGhleCA9IFN0cmluZy5zdWIgaGV4c3RyIDAgMiBpbgogICAgbGV0IHRvcGludCA9IGludF9vZl9zdHJpbmcgKCIweCIgXiB0b3BoZXgpIGluCiAgICBsZXQgbmV3cmF3c3RyID0gcmF3c3RyIF4gKENoYXIuY2hyIHRvcGludCkgaW4KICAgIGxldCByZW1sZW4gPSAoU3RyaW5nLmxlbmd0aCBoZXhzdHIpIC0gMiAgaW4KICAgIGxldCBuZXdoZXhyYXcgPSBTdHJpbmcuc3ViIDIgcmVtbGVuIGluCiAgICBpZiByZW1sZW4gPT0gMCB0aGVuIG5ld3Jhd3N0ciAKICAgIGVsc2UgaGV4cmF3IG5ld2hleHJhdyBuZXdyYXdzdHIKICBoZXhyYXcgaGV4c3RyaW5nICIiIDs7CgpoZXhfdG9fcmF3ICJiYWRmMDBkIgoKCmxldCBiNjRfdG9fcmF3IGI2NHN0cmluZyA9CiAgcmF3c3RyaW5nIDs7CgpsZXQgcmF3X3RvX2hleCByYXdzdHJpbmcgPQogIHJhd3N0cmluZyA7OwoKbGV0IHJhd190b19iNjQgcmF3c3RyaW5nID0KICByYXdzdHJpbmcgOzsKClByaW50Zi5wcmludGYgIiVzIiAocmF3X3RvX2I2NCAoaGV4X3RvX3JhdyAiYmFkZjAwZCIpKQoKCg==