File
Blob: archive/str0m-probe/vendor/str0m-rust-crypto/src/sha256.rs
| 1 | //! RustCrypto SHA-256 implementation. |
| 2 | |
| 3 | use sha2::{Digest, Sha256}; |
| 4 | |
| 5 | use str0m_proto::crypto::Sha256Provider; |
| 6 | |
| 7 | /// RustCrypto-based SHA-256 provider. |
| 8 | #[derive(Debug)] |
| 9 | pub struct RustCryptoSha256Provider; |
| 10 | |
| 11 | impl Sha256Provider for RustCryptoSha256Provider { |
| 12 | fn sha256(&self, data: &[u8]) -> [u8; 32] { |
| 13 | let mut hasher = Sha256::new(); |
| 14 | hasher.update(data); |
| 15 | hasher.finalize().into() |
| 16 | } |
| 17 | } |