23 lines
593 B
OCaml
23 lines
593 B
OCaml
|
(**
|
||
|
* Copyright (c) 2015, Fabien Freling
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* This source code is licensed under the BSD 2-clause license found in the
|
||
|
* LICENSE file at the top level directory of this source tree.
|
||
|
*)
|
||
|
|
||
|
open Printf
|
||
|
|
||
|
let rec print_slice ?(width=8) b start last =
|
||
|
if start < last then
|
||
|
let max = min (start + width - 1) last in
|
||
|
for i = start to max do
|
||
|
printf "%02X " (Bytes.get b i |> int_of_char)
|
||
|
done;
|
||
|
print_newline ();
|
||
|
print_slice ~width b (start + width) last
|
||
|
|
||
|
let print_bytes ?(width=8) b width =
|
||
|
let l = Bytes.length b in
|
||
|
print_slice ~width b 0 l
|