Switch from sha256sum to sha512sum
Not needed but it will be consistant with the launcher itself
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use sha2::{Digest, Sha256};
|
||||
use sha2::{Digest, Sha512};
|
||||
use std::{
|
||||
fs::{File, create_dir_all},
|
||||
io::{BufReader, copy},
|
||||
@@ -42,8 +42,8 @@ async fn unzip_to_dir(zip_path: PathBuf, out_dir: PathBuf) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_sha256_hash(data: &[u8]) -> String {
|
||||
let mut hasher = Sha256::new();
|
||||
fn get_sha512_hash(data: &[u8]) -> String {
|
||||
let mut hasher = Sha512::new();
|
||||
hasher.update(data);
|
||||
let hash = hasher.finalize();
|
||||
format!("{:x}", hash)
|
||||
@@ -74,7 +74,7 @@ async fn download(app: AppHandle, url: String, name: String, hash: String) -> St
|
||||
Err(_) => return "-1".to_string(),
|
||||
};
|
||||
|
||||
let download_hash = get_sha256_hash(&bytes);
|
||||
let download_hash = get_sha512_hash(&bytes);
|
||||
if hash != download_hash {
|
||||
return "-2".to_string();
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ export default function Home () {
|
||||
|
||||
const findUrl = (plat: string) => {
|
||||
const i = version.platforms.indexOf(plat)
|
||||
return i >= 0 ? version.sha256sums[i] : undefined
|
||||
return i >= 0 ? version.sha512sums[i] : undefined
|
||||
}
|
||||
|
||||
if (p === 'windows') {
|
||||
|
||||
@@ -3,5 +3,5 @@ export interface LauncherUpdate {
|
||||
releaseDate: number
|
||||
downloadUrls: string[]
|
||||
platforms: string[]
|
||||
sha256sums: string[]
|
||||
sha512sums: string[]
|
||||
}
|
||||
Reference in New Issue
Block a user