diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 871b0f60d7..6e7c108582 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -8338,7 +8338,7 @@ dependencies = [ "secrecy", "serde", "serde_json", - "sha2 0.8.2", + "sha2 0.9.2", "sp-debug-derive", "sp-externalities", "sp-runtime-interface", diff --git a/substrate/primitives/core/Cargo.toml b/substrate/primitives/core/Cargo.toml index de06ecd87e..50c57e068d 100644 --- a/substrate/primitives/core/Cargo.toml +++ b/substrate/primitives/core/Cargo.toml @@ -46,7 +46,7 @@ ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_ blake2-rfc = { version = "0.2.18", default-features = false, optional = true } tiny-keccak = { version = "2.0.1", features = ["keccak"], optional = true } schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false, optional = true } -sha2 = { version = "0.8.0", default-features = false, optional = true } +sha2 = { version = "0.9.2", default-features = false, optional = true } hex = { version = "0.4", default-features = false, optional = true } twox-hash = { version = "1.5.0", default-features = false, optional = true } libsecp256k1 = { version = "0.3.2", default-features = false, features = ["hmac"], optional = true } diff --git a/substrate/primitives/core/src/hashing.rs b/substrate/primitives/core/src/hashing.rs index 8a4c5191dd..0b67d33235 100644 --- a/substrate/primitives/core/src/hashing.rs +++ b/substrate/primitives/core/src/hashing.rs @@ -77,7 +77,7 @@ pub fn blake2_64(data: &[u8]) -> [u8; 8] { /// Do a XX 64-bit hash and place result in `dest`. pub fn twox_64_into(data: &[u8], dest: &mut [u8; 8]) { - use ::core::hash::Hasher; + use core::hash::Hasher; let mut h0 = twox_hash::XxHash::with_seed(0); h0.write(data); let r0 = h0.finish(); @@ -94,7 +94,7 @@ pub fn twox_64(data: &[u8]) -> [u8; 8] { /// Do a XX 128-bit hash and place result in `dest`. pub fn twox_128_into(data: &[u8], dest: &mut [u8; 16]) { - use ::core::hash::Hasher; + use core::hash::Hasher; let mut h0 = twox_hash::XxHash::with_seed(0); let mut h1 = twox_hash::XxHash::with_seed(1); h0.write(data); @@ -163,8 +163,8 @@ pub fn keccak_512(data: &[u8]) -> [u8; 64] { /// Do a sha2 256-bit hash and return result. pub fn sha2_256(data: &[u8]) -> [u8; 32] { let mut hasher = Sha256::new(); - hasher.input(data); + hasher.update(data); let mut output = [0u8; 32]; - output.copy_from_slice(&hasher.result()); + output.copy_from_slice(&hasher.finalize()); output }