pub struct HashHelper;Expand description
High-level hash helper providing convenient hashing operations
Implementations§
Source§impl HashHelper
impl HashHelper
Sourcepub fn sha256_hex(data: &[u8]) -> String
pub fn sha256_hex(data: &[u8]) -> String
Compute SHA-256 hash of raw bytes and return as hex string
Sourcepub fn sha256_json(json_data: &Value) -> [u8; 32]
pub fn sha256_json(json_data: &Value) -> [u8; 32]
Compute SHA-256 hash of JSON data
Sourcepub fn sha256_json_hex(json_data: &Value) -> String
pub fn sha256_json_hex(json_data: &Value) -> String
Compute SHA-256 hash of JSON data and return as hex string
Sourcepub fn bytes_to_hex(bytes: &[u8]) -> String
pub fn bytes_to_hex(bytes: &[u8]) -> String
Convert bytes to hex string
Sourcepub fn hex_to_bytes(hex_str: &str) -> Result<Vec<u8>, FromHexError>
pub fn hex_to_bytes(hex_str: &str) -> Result<Vec<u8>, FromHexError>
Convert hex string to bytes
Sourcepub fn hash_string(data: &str) -> [u8; 32]
pub fn hash_string(data: &str) -> [u8; 32]
Compute hash of string data
Sourcepub fn hash_string_hex(data: &str) -> String
pub fn hash_string_hex(data: &str) -> String
Compute hash of string data and return as hex
Sourcepub fn double_hash(data: &[u8]) -> [u8; 32]
pub fn double_hash(data: &[u8]) -> [u8; 32]
Create a double hash (hash of hash)
Sourcepub fn double_hash_hex(data: &[u8]) -> String
pub fn double_hash_hex(data: &[u8]) -> String
Create a double hash and return as hex
Sourcepub fn bytes_equal(a: &[u8], b: &[u8]) -> bool
pub fn bytes_equal(a: &[u8], b: &[u8]) -> bool
Verify that two byte arrays are equal
Sourcepub fn verify_hash(data: &[u8], expected_hash: &[u8; 32]) -> bool
pub fn verify_hash(data: &[u8], expected_hash: &[u8; 32]) -> bool
Verify hash matches expected value
Sourcepub fn verify_hash_hex(data: &[u8], expected_hex: &str) -> bool
pub fn verify_hash_hex(data: &[u8], expected_hex: &str) -> bool
Verify hash matches expected hex value
Trait Implementations§
Source§impl Clone for HashHelper
impl Clone for HashHelper
Source§fn clone(&self) -> HashHelper
fn clone(&self) -> HashHelper
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HashHelper
impl Debug for HashHelper
impl Copy for HashHelper
Auto Trait Implementations§
impl Freeze for HashHelper
impl RefUnwindSafe for HashHelper
impl Send for HashHelper
impl Sync for HashHelper
impl Unpin for HashHelper
impl UnsafeUnpin for HashHelper
impl UnwindSafe for HashHelper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more