pub struct Hash { /* private fields */ }Expand description
Hash subsystem.
Provides hardware-accelerated hash functions including SHA-2, SHA-3, SHAKE, HMAC, and HKDF.
§Example
use quantacore::{initialize, open_first_device, HashAlgorithm};
initialize().unwrap();
let device = open_first_device().unwrap();
let hash = device.hash();
// One-shot hashing
let digest = hash.sha256(b"Hello, World!").unwrap();
println!("SHA-256: {}", hex::encode(&digest));
// Incremental hashing
let mut ctx = hash.create_context(HashAlgorithm::Sha3_256).unwrap();
ctx.update(b"Hello, ").unwrap();
ctx.update(b"World!").unwrap();
let digest = ctx.finalize().unwrap();Implementations§
Source§impl Hash
impl Hash
Sourcepub fn shake128(&self, data: &[u8], output_len: usize) -> Result<Vec<u8>>
pub fn shake128(&self, data: &[u8], output_len: usize) -> Result<Vec<u8>>
Compute SHAKE128 output.
§Arguments
data- The input dataoutput_len- The desired output length in bytes
Sourcepub fn shake256(&self, data: &[u8], output_len: usize) -> Result<Vec<u8>>
pub fn shake256(&self, data: &[u8], output_len: usize) -> Result<Vec<u8>>
Compute SHAKE256 output.
§Arguments
data- The input dataoutput_len- The desired output length in bytes
Sourcepub fn create_context(&self, algorithm: HashAlgorithm) -> Result<HashContext>
pub fn create_context(&self, algorithm: HashAlgorithm) -> Result<HashContext>
Create a hash context for incremental hashing.
§Example
let mut ctx = hash.create_context(HashAlgorithm::Sha256).unwrap();
ctx.update(b"part 1").unwrap();
ctx.update(b"part 2").unwrap();
let digest = ctx.finalize().unwrap();Trait Implementations§
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnwindSafe for Hash
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)