decryptHmacSha256 static method
Returns the original value used to create the HMAC-SHA256 hash.
This function accepts an encrypted base64 string and attempts to decode it back to its original form.
Note: This doesn't decrypt the actual HMAC-SHA256 hash (which is one-way), but it decodes the base64 representation back to the bytes of the hash.
Parameters:
- encryptedValue: The Base64 encoded string to decode
Returns: The decoded string representation of the hash value
Implementation
static String decryptHmacSha256({required String encryptedValue}) {
try {
// Decode the base64 string back to bytes
List<int> bytes = base64Decode(encryptedValue);
// Convert the bytes to a hexadecimal string representation
return bytes.map((byte) => byte.toRadixString(16).padLeft(2, '0')).join();
} catch (e) {
// Return empty string if decoding fails
return '';
}
}