aboutsummaryrefslogblamecommitdiffstats
path: root/lib/interop.ml
blob: 8cbc05c5dae9a33c9f5b55dd403b1cb7a427159f (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                      
                 

                                




                                                                        
open Ctypes

module Sha256 = struct
  type t = string

  let compute_hash content : t =
    let size_with_null_terminator = C.Types.hash_size + 1 in
    let buf = Ctypes.allocate_n char ~count:size_with_null_terminator in
    let () = C.Functions.compute_hash buf (Bytes.to_string content) in
    Ctypes.coerce (ptr char) Ctypes.string buf
end