read bytes instead of string
This commit is contained in:
parent
e65667fe4b
commit
b7336fc0b1
1 changed files with 7 additions and 12 deletions
19
src/hash.rs
19
src/hash.rs
|
@ -41,7 +41,7 @@ impl Buster {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hasher(payload: &str) -> String {
|
fn hasher(payload: &[u8]) -> String {
|
||||||
use data_encoding::HEXUPPER;
|
use data_encoding::HEXUPPER;
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
|
@ -131,19 +131,14 @@ impl Buster {
|
||||||
Ok(file_map)
|
Ok(file_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_to_string(path: &Path) -> Result<String, Error> {
|
fn read_to_string(path: &Path) -> Result<Vec<u8>, Error> {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufRead, BufReader};
|
use std::io::Read;
|
||||||
|
|
||||||
let input = File::open(path)?;
|
let mut file_content = Vec::new();
|
||||||
let buffered = BufReader::new(input);
|
let mut file = File::open(path)?;
|
||||||
|
file.read_to_end(&mut file_content).expect("Unable to read");
|
||||||
let mut res = String::new();
|
Ok(file_content)
|
||||||
for line in buffered.lines() {
|
|
||||||
res.push_str(&line?)
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_map<'a>(&self, source: &'a Path, name: &str) -> (&'a Path, PathBuf) {
|
fn gen_map<'a>(&self, source: &'a Path, name: &str) -> (&'a Path, PathBuf) {
|
||||||
|
|
Loading…
Reference in a new issue