amebazii::util

Function sha256

Source
pub fn sha256(data: &[u8]) -> Result<[u8; 32], Error>
Expand description

Computes a SHA-256 hash of the provided data.

This function computes the SHA-256 hash of the input data. The result is the 256-bit (32-byte) hash.

§Parameters

  • data: A byte slice containing the data to be hashed.

§Returns

  • [u8; 32]: A 32-byte array containing the computed SHA-256 hash.
  • Err(error::Error): An error if there is a failure during the hashing process.

§Example

use my_crate::sha256;
let data = b"message";
let hash = sha256(data).unwrap();
assert_eq!(hash.len(), 32); // The SHA-256 hash should be 32 bytes.

§Errors

This function may return an error if there is a failure during the SHA-256 hashing process.