Skip to content

Commit 28b3ef0

Browse files
committed
Change sha256 to sha384
Changes Sha256 usage into sha384 . Addresses oscar-project#108
1 parent 58aa6c4 commit 28b3ef0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/processing/package.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Packaging is in two steps:
44
- First, we create a folder for each present language, and we move language files (text and metadata) into them
5-
- Then, we compute a sha256sum for each file, and write them into language independent files, _usually_ compatible with `sha256sum -c` implementations.
5+
- Then, we compute a sha384sum for each file, and write them into language independent files, _usually_ compatible with `sha384sum -c` implementations.
66
!*/
77
use log::warn;
88
use rayon::prelude::*;
@@ -15,7 +15,7 @@ use std::path::PathBuf;
1515
use log::error;
1616
use log::{debug, info};
1717
use sha2::Digest;
18-
use sha2::Sha256;
18+
use sha2::Sha384;
1919

2020
use crate::error::Error;
2121
// use crate::lang::LANG;
@@ -27,7 +27,7 @@ pub fn gen_checksum_file(src: &Path, lang: &'static str) -> Result<(), Error> {
2727
src_lang.push(lang);
2828

2929
debug!("gen checksum on folder {:?}", src_lang);
30-
let mut hasher = Sha256::new();
30+
let mut hasher = Sha384::new();
3131
let files: Vec<_> = std::fs::read_dir(&src_lang)?.collect();
3232

3333
debug!("files to hash: {:#?}", files);
@@ -46,7 +46,7 @@ pub fn gen_checksum_file(src: &Path, lang: &'static str) -> Result<(), Error> {
4646
// forge filepath of checksum file
4747
let checksum_filepath: PathBuf = [
4848
src_lang,
49-
Path::new(&format!("{}_sha256.txt", lang)).to_path_buf(),
49+
Path::new(&format!("{}_sha384.txt", lang)).to_path_buf(),
5050
]
5151
.iter()
5252
.collect();
@@ -55,7 +55,7 @@ pub fn gen_checksum_file(src: &Path, lang: &'static str) -> Result<(), Error> {
5555
// open it
5656
let mut checksum_file = File::create(checksum_filepath)?;
5757

58-
// write filenames and hashes in sha256sum -c compatible format.
58+
// write filenames and hashes in sha384sum -c compatible format.
5959
for (filename, hash) in filenames.iter().zip(hashes) {
6060
writeln!(&mut checksum_file, "{} {}", hash, filename)?;
6161
}
@@ -67,7 +67,7 @@ pub fn gen_checksum_file(src: &Path, lang: &'static str) -> Result<(), Error> {
6767
/// As such, it shouldn't make the program go OOM with big files, but it has not been tested.
6868
/// Can return an error if there has been problems regarding IO.
6969
#[inline]
70-
fn get_hash(filepath: &Path, hasher: &mut Sha256) -> Result<String, Error> {
70+
fn get_hash(filepath: &Path, hasher: &mut Sha384) -> Result<String, Error> {
7171
let mut f = File::open(filepath)?;
7272
io::copy(&mut f, hasher)?;
7373
let result = format!("{:x}", hasher.finalize_reset());
@@ -104,7 +104,7 @@ fn put_in_lang_folder(
104104
}
105105

106106
/// Iteratively moves each file corresponding to `lang` into a proper folder named by the language id,
107-
/// then computes sha256sum for each file.
107+
/// then computes sha384sum for each file.
108108
///
109109
/// - `src` is the corpus location, containing language files in compressed format.
110110
/// - `dst` is the packaged corpus location.
@@ -184,7 +184,7 @@ fn package_lang(
184184
}
185185

186186
/// concurrently package all the languages present in `src` (split and compressed) to `dst`
187-
/// in separate language folders along with a `sha256sum -c`-able file.
187+
/// in separate language folders along with a `sha384sum -c`-able file.
188188
pub fn package(src: &Path, dst: Option<&Path>, move_files: bool) -> Result<(), Error> {
189189
let langs = LANG.clone().into_par_iter();
190190
let results: Vec<Error> = langs

tests/oscardoc_rebuild.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// gen a tiny corpus from one shard
22
// get the rebuild files
33
// regen the corpus from the rebuild files
4-
// ensure that the rebuilt corpus files are similar to the original ones (to the sha256sum)
4+
// ensure that the rebuilt corpus files are similar to the original ones (to the sha384sum)
55

66
use std::{
77
fs::File,

0 commit comments

Comments
 (0)