mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-04 14:07:18 +08:00 
			
		
		
		
	feat(events): add hashed customer_email and feature_metadata (#5220)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										22
									
								
								crates/common_utils/src/hashing.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								crates/common_utils/src/hashing.rs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
use masking::{PeekInterface, Secret, Strategy};
 | 
			
		||||
use serde::{Deserialize, Serialize, Serializer};
 | 
			
		||||
 | 
			
		||||
#[derive(Clone, Debug, Deserialize)]
 | 
			
		||||
/// Represents a hashed string using blake3's hashing strategy.
 | 
			
		||||
pub struct HashedString<T: Strategy<String>>(Secret<String, T>);
 | 
			
		||||
 | 
			
		||||
impl<T: Strategy<String>> Serialize for HashedString<T> {
 | 
			
		||||
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 | 
			
		||||
    where
 | 
			
		||||
        S: Serializer,
 | 
			
		||||
    {
 | 
			
		||||
        let hashed_value = blake3::hash(self.0.peek().as_bytes()).to_hex();
 | 
			
		||||
        hashed_value.serialize(serializer)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<T: Strategy<String>> From<Secret<String, T>> for HashedString<T> {
 | 
			
		||||
    fn from(value: Secret<String, T>) -> Self {
 | 
			
		||||
        Self(value)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user