mllib: add SHA1 support in Checksums

This way Checksums can be used in v2v.
This commit is contained in:
Pino Toscano
2016-09-30 11:09:13 +02:00
parent a58dff49c5
commit 484c64c29f
2 changed files with 6 additions and 0 deletions

View File

@@ -22,21 +22,25 @@ open Common_utils
open Printf
type csum_t =
| SHA1 of string
| SHA256 of string
| SHA512 of string
exception Mismatched_checksum of (csum_t * string)
let string_of_csum_t = function
| SHA1 _ -> "sha1"
| SHA256 _ -> "sha256"
| SHA512 _ -> "sha512"
let string_of_csum = function
| SHA1 c -> c
| SHA256 c -> c
| SHA512 c -> c
let of_string csum_type csum_value =
match String.lowercase_ascii csum_type with
| "sha1" -> SHA1 csum_value
| "sha256" -> SHA256 csum_value
| "sha512" -> SHA512 csum_value
| _ -> invalid_arg csum_type
@@ -44,6 +48,7 @@ let of_string csum_type csum_value =
let verify_checksum csum filename =
let prog, csum_ref =
match csum with
| SHA1 c -> "sha1sum", c
| SHA256 c -> "sha256sum", c
| SHA512 c -> "sha512sum", c
in

View File

@@ -17,6 +17,7 @@
*)
type csum_t =
| SHA1 of string
| SHA256 of string
| SHA512 of string