Skip to content

Commit

Permalink
Replace 'crypto' crate with 'sha2' (close snowplow-archive#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Leonard committed Oct 22, 2021
1 parent 8063b44 commit e881933
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ hyper-native-tls = "0.3.0"
libc = "0.2.17"
ifaces = "0.0.3"
dns-lookup = "0.2.1"
sha2 = "0.9.8"
19 changes: 9 additions & 10 deletions src/factotum/webhook/jobcontext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ mod tests;

use chrono::DateTime;
use chrono::UTC;
use crypto::digest::Digest;
use crypto::sha2::Sha256;
use rustc_serialize::base64::{ToBase64, MIME};
use sha2::{Digest, Sha256};
use std::collections::HashMap;
use uuid::Uuid;

Expand All @@ -43,22 +42,22 @@ impl JobContext {
let ff = factfile;

let mut job_digest = Sha256::new();
job_digest.input_str(&ff);
job_digest.update(&ff);

if let Some(ref tags_map) = tags {
let mut sorted_keys: Vec<_> = tags_map.keys().collect();
sorted_keys.sort();
for key in sorted_keys {
job_digest.input_str(key);
job_digest.input_str(&tags_map[key]);
job_digest.update(key);
job_digest.update(&tags_map[key]);
}
}

let job_ref = job_digest.result_str();
let job_ref = job_digest.finalize();

let mut run_digest = Sha256::new();
run_digest.input_str(&format!("{}", Uuid::new_v4()));
let run_ref = run_digest.result_str();
run_digest.update(&format!("{}", Uuid::new_v4()));
let run_ref = run_digest.finalize();

let mut config = MIME;
config.line_length = None;
Expand All @@ -72,8 +71,8 @@ impl JobContext {

JobContext {
job_name: job_name.into(),
job_reference: job_ref,
run_reference: run_ref,
job_reference: format!("{:x}", job_ref),
run_reference: format!("{:x}", run_ref),
factfile: b64_ff,
factotum_version: env!("CARGO_PKG_VERSION").to_string(),
start_time: UTC::now(),
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern crate libc;
extern crate log4rs;
extern crate rand;
extern crate rustc_serialize;
extern crate sha2;
extern crate uuid;
extern crate valico;

Expand Down

0 comments on commit e881933

Please sign in to comment.