pakery_crypto/hash.rs
1//! SHA-512 implementation of the Hash trait.
2
3use alloc::vec::Vec;
4use pakery_core::crypto::Hash;
5use sha2::Digest;
6
7/// SHA-512 hash function.
8#[derive(Clone)]
9pub struct Sha512Hash {
10 inner: sha2::Sha512,
11}
12
13impl Hash for Sha512Hash {
14 const OUTPUT_SIZE: usize = 64;
15
16 fn new() -> Self {
17 Self {
18 inner: sha2::Sha512::new(),
19 }
20 }
21
22 fn update(&mut self, data: &[u8]) {
23 self.inner.update(data);
24 }
25
26 fn finalize(self) -> Vec<u8> {
27 self.inner.finalize().to_vec()
28 }
29}