Skip to content

Commit

Permalink
Merge pull request #1190 from marxin/replace-md5-with-sha256
Browse files Browse the repository at this point in the history
Replace unsecure md5 with sha256 algorithm
  • Loading branch information
sagiegurari authored Jan 18, 2025
2 parents 1e0969c + 677f5ca commit 5b668ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ fern = "^0.7"
fsio = { version = "^0.4", features = ["temp-path"] }
git_info = "^0.1.3"
glob = "^0.3.2"
hex = "0.4.3"
home = "^0.5"
ignore = "^0.4"
indexmap = { version = "^2", features = ["serde"] }
itertools = "^0.14"
lenient_semver = "^0.4.2"
log = "^0.4"
md5 = "^0.7"
once_cell = "^1.20.2"
petgraph = "^0.7.1"
regex = "^1.11"
Expand All @@ -74,6 +74,7 @@ serde = "^1"
serde_derive = "^1"
serde_ignored = "^0.1"
serde_json = "^1"
sha2 = "0.10.8"
shell2batch = "^0.4.5"
strip-ansi-escapes = "^0.2"
strum_macros = "0.26.4"
Expand Down
7 changes: 4 additions & 3 deletions src/lib/scriptengine/script_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::error::CargoMakeError;
use crate::io::create_text_file;
use fsio::file::write_text_file;
use fsio::path::as_path::AsPath;
use md5;
use sha2::{Digest, Sha256};
use std::path::PathBuf;

pub(crate) fn create_script_file(
Expand Down Expand Up @@ -44,8 +44,9 @@ fn create_persisted_script_file_with_options(
let text = script_text.join("\n");

let string_bytes = text.as_bytes();
let bytes = md5::compute(string_bytes);
let mut file_name = format!("{:x}", bytes);
let mut hasher = Sha256::new();
hasher.update(string_bytes);
let mut file_name = hex::encode(hasher.finalize());

let default_target_directory = envmnt::get_or("CARGO_MAKE_CRATE_TARGET_DIRECTORY", "target");
let directory = envmnt::get_or(
Expand Down

0 comments on commit 5b668ad

Please sign in to comment.