/// Function used to download Wix and VC_REDIST. Checks SHA256 to verify the download.
Function used to download Wix and VC_REDIST. Checks SHA256 to verify the download.
Function used to download Wix and VC_REDIST . Checks SHA256 to verify the download .
fn download_and_verify(url: &str, hash: &str) -> crate::Result<Vec<u8>> {
  common::print_info(format!("Downloading {}", url).as_str())?;
  let response = attohttpc::get(url).send()?;
  let data: Vec<u8> = response.bytes()?;
  common::print_info("validating hash")?;
  let mut hasher = sha2::Sha256::new();
  hasher.update(&data);
  let url_hash = hasher.finalize().to_vec();
  let expected_hash = hex::decode(hash)?;
  if expected_hash == url_hash {
    Ok(data)
  } else {
    Err(crate::Error::HashError)
  }
}
fn download_and_verify ( url : & str , hash : & str ) -> crate :: Result < Vec < u8 > > { common :: print_info ( format ! ( " " url ) . as_str ( ) ) ? ; let response = attohttpc :: get ( url ) . send ( ) ? ; let data : Vec < u8 > = response . bytes ( ) ? ; common :: print_info ( " " ) ? ; let mut hasher = sha2 :: Sha256 :: new ( ) ; hasher . update ( & data ) ; let url_hash = hasher . finalize ( ) . to_vec ( ) ; let expected_hash = hex :: decode ( hash ) ? ; if expected_hash == url_hash { Ok ( data ) } else { Err ( crate :: Error :: HashError ) } }
Function used to download Wix and VC_REDIST.
Function used to download Wix and VC_REDIST .
url
&str
hash
&str