bitcoin-sha256 0.1.20

SHA-256 and SHA-512 are novel hash functions computed with eight 32-bit and 64-bit words, respectively. They use different shift amounts and additive constants, but their structures are otherwise virtually identical, differing only in the number of rounds. (from wikipedia)
// ---------------- [ File: bitcoin-sha256/src/compute.rs ]
crate::ix!();

pub trait ComputeSha256 {
    fn sha256(&self) -> u256;
}

/**
  | Single-SHA256 a 32-byte input (represented
  | as uint256).
  |
  */
pub fn sha256uint256(input: &u256) -> u256 {
    input.sha256()
}

impl ComputeSha256 for u256 {
    fn sha256(&self) -> u256 {
        let mut result = u256::zero();
        let mut sha = Sha256::new();
        sha.write(self.as_ref());
        sha.finalize(result.as_mut_slice_exact());
        result
    }
}