Skip to main content

crypto_dispatch/algorithms/
sha3_256.rs

1// SPDX-FileCopyrightText: Copyright © 2026 ReallyMe LLC. All rights reserved
2//
3// SPDX-License-Identifier: Apache-2.0
4
5use crate::traits::HashDigestAlgorithm;
6use crate::AlgorithmError;
7use crypto_core::HashAlgorithm;
8
9/// SHA3-256 hash adapter.
10pub struct Sha3_256Algo;
11
12impl HashDigestAlgorithm for Sha3_256Algo {
13    const ALG: HashAlgorithm = HashAlgorithm::Sha3_256;
14
15    fn digest(message: &[u8]) -> Result<Vec<u8>, AlgorithmError> {
16        let digest = crypto_sha3_256::digest(message);
17        Ok(digest.as_bytes().to_vec())
18    }
19}