Data hashing & transformation
Overview
The rated-parser
library provides powerful data processing capabilities with built-in privacy features to help you handle sensitive data responsibly. This guide explains how to use these features while maintaining GDPR compliance.
Field Processing Options
Basic Field Definition
Every field in your metrics is defined by a key
that maps to the corresponding value in your data. For example:
Privacy Protection Options
1. Encryption
Use encryption when you need to retrieve the original value later (e.g., for debugging or customer support).
Example Use Cases:
User identifiers
Email addresses
IP addresses
Session IDs
When processed, the email becomes an encrypted string that can only be decrypted with your encryption key:
2. Hashing
Use hashing when you need to track metrics without storing the original value. Hashed values cannot be reversed.
Our implementation uses:
Algorithm: SHA-256
Encoding: UTF-8
Output Format: Hexadecimal digest (64 characters)
These specifications ensure consistent hash generation across different systems. The code implementation is:
Example Use Cases:
Organization IDs for analytics
Device IDs for unique user counting
Transaction IDs for deduplication
Results in:
Data Transformations
1. Expression Transformations
Use expressions when you need to modify values using simple mathematical or string operations.
Example Use Cases:
Converting units (bytes to MB, seconds to milliseconds)
Normalizing string formats
Basic calculations
This transforms memory usage from bytes to MB:
2. Function Transformations
Use predefined functions for more complex transformations.
Example Use Cases:
Duration string parsing
HTTP status code categorization
String normalization
This converts duration strings to milliseconds:
Built-in Safety Features
Field Protection:
Cannot combine encryption and hashing on the same field
Automatic validation of transformation expressions
Protection against injection attacks
Transformation Safety:
Restricted to safe mathematical operations
Limited to approved string methods
No access to system functions or dangerous operations
Example Implementation
Here's a complete example showing different types of field processing:
Input data:
Output data:
This processed data is now ready for storage or analysis while maintaining privacy and compliance requirements.
Last updated