| Anonymous | Login | Signup for a new account | 2013-05-25 14:54 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | |||
| 0001835 | OCaml | OCaml general | public | 2003-09-15 21:17 | 2012-01-26 23:57 | |||
| Reporter | administrator | |||||||
| Assigned To | ||||||||
| Priority | normal | Severity | feature | Reproducibility | always | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | ||||||||
| Target Version | Fixed in Version | 3.13.0+dev | ||||||
| Summary | 0001835: Digest function to transform a md5sum string into a Digest.t | |||||||
| Description | Hello, I think that a usefull addition to the Digest module would be one that allowed to transform a 32 character md5sum string (as outputed by md5sum for example) into a Digest.t. I have here a quick and dirty implementation of such a function : let md5sum_of_string s = let digest = String.make 16 (char_of_int 0) in let len = String.length s in if len <> 32 then failwith "Not a md5sum" else let int_of_hex c = match c with | '0' .. '9' -> (int_of_char c) - 48 | 'a' .. 'f' -> (int_of_char c) - 87 | 'A' .. 'F' -> (int_of_char c) - 55 | _ -> failwith "Not an hex" in let rec convert_byte i = if i = 0 then () else begin digest.[i-1] <- char_of_int ((int_of_hex s.[2*i-1]) + 16 * (int_of_hex s.[2*i-2])); convert_byte (i-1) end in convert_byte 16; digest It is not very elegant, and may not be endian clean or something such, but it does the job, and i include it here to more explain what i meant. Maybe this can be added still in time for 3.07. Friendly, Sven Luther | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0006815) doligez (manager) 2012-01-26 23:57 |
Implemented as Digest.from_hex in trunk [3.13.0] (commit 12082). |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2005-11-18 10:13 | administrator | New Issue | |
| 2012-01-26 23:57 | doligez | Note Added: 0006815 | |
| 2012-01-26 23:57 | doligez | Status | acknowledged => closed |
| 2012-01-26 23:57 | doligez | Resolution | open => fixed |
| 2012-01-26 23:57 | doligez | Fixed in Version | => 3.13.0+dev |
| 2012-01-26 23:57 | doligez | Description Updated | View Revisions |
| Copyright © 2000 - 2011 MantisBT Group |