fork download
  1. (* hex to raw bytes *)
  2. let rec hex_to_raw hexstring =
  3. let rec hexraw hexstr rawstr =
  4. let tophex = String.sub hexstr 0 2 in
  5. let topint = int_of_string ("0x" ^ tophex) in
  6. let newrawstr = rawstr ^ (Char.chr topint) in
  7. let remlen = (String.length hexstr) - 2 in
  8. let newhexraw = String.sub 2 remlen in
  9. if remlen == 0 then newrawstr
  10. else hexraw newhexraw newrawstr
  11. hexraw hexstring "" ;;
  12.  
  13. hex_to_raw "badf00d"
  14.  
  15.  
  16. let b64_to_raw b64string =
  17. rawstring ;;
  18.  
  19. let raw_to_hex rawstring =
  20. rawstring ;;
  21.  
  22. let raw_to_b64 rawstring =
  23. rawstring ;;
  24.  
  25. Printf.printf "%s" (raw_to_b64 (hex_to_raw "badf00d"))
  26.  
  27.  
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
File "prog.ml", line 11, characters 22-24:
Syntax error
stdout
Standard output is empty