daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/stdlib/digest.ml b/stdlib/digest.ml
  2. index aee6cd2..dea7397 100644
  3. --- a/stdlib/digest.ml
  4. +++ b/stdlib/digest.ml
  5. @@ -42,10 +42,14 @@ let input chan =
  6.    really_input chan digest 0 16;
  7.    digest
  8.  
  9. +let char_hex n = Char.chr (n + if n < 10 then Char.code '0' else (Char.code 'a' - 10))
  10. +
  11.  let to_hex d =
  12.    let result = String.create 32 in
  13.    for i = 0 to 15 do
  14. -    String.blit (Printf.sprintf "%02x" (int_of_char d.[i])) 0 result (2*i) 2;
  15. +    let x = Char.code (String.unsafe_get d i) in
  16. +    String.unsafe_set result (i*2) (char_hex (x lsr 4));
  17. +    String.unsafe_set result (i*2+1) (char_hex (x land 0x0f));
  18.    done;
  19.    result
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top