update crypto dependencies to new crates
This commit is contained in:
+4
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "digest_auth"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
authors = ["Ondřej Hruška <ondra@ondrovo.com>"]
|
||||
edition = "2018"
|
||||
description = "Implementation of the Digest Auth algorithm as defined in IETF RFC 2069, 2617, and 7616, intended for HTTP clients"
|
||||
@@ -15,6 +15,8 @@ categories = [
|
||||
license = "MIT"
|
||||
|
||||
[dependencies]
|
||||
rust-crypto = "0.2"
|
||||
rand = "0.6"
|
||||
hex = "0.3.2"
|
||||
sha2 = "0.8.0"
|
||||
md-5 = "0.8.0"
|
||||
digest = "0.8.1"
|
||||
|
||||
+6
-3
@@ -1,9 +1,12 @@
|
||||
use crate::{Error, Error::*, Result};
|
||||
use crypto::{digest::Digest, md5::Md5, sha2::Sha256, sha2::Sha512Trunc256};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
|
||||
use digest::{Digest, DynDigest};
|
||||
use md5::Md5;
|
||||
use sha2::{Sha256, Sha512Trunc256};
|
||||
|
||||
/// Algorithm type
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
#[allow(non_camel_case_types)]
|
||||
@@ -28,14 +31,14 @@ impl Algorithm {
|
||||
|
||||
/// Calculate a hash of bytes using the selected algorithm
|
||||
pub fn hash(&self, bytes: &[u8]) -> String {
|
||||
let mut hash: Box<dyn Digest> = match self.algo {
|
||||
let mut hash : Box<dyn DynDigest> = match self.algo {
|
||||
AlgorithmType::MD5 => Box::new(Md5::new()),
|
||||
AlgorithmType::SHA2_256 => Box::new(Sha256::new()),
|
||||
AlgorithmType::SHA2_512_256 => Box::new(Sha512Trunc256::new()),
|
||||
};
|
||||
|
||||
hash.input(bytes);
|
||||
hash.result_str()
|
||||
hex::encode(hash.result())
|
||||
}
|
||||
|
||||
/// Calculate a hash of string's bytes using the selected algorithm
|
||||
|
||||
Reference in New Issue
Block a user