Webhooks
Decrypt webhook
These are the requirements and steps for decrypting a Webhook.
When you create the new Webhook in the response you get two attributes;
Secret is used to decrypt the webhook payload.
Standard decryption for aes-256-cbc using the data, the iv, and the secret returned during the webhook registration.
1
Extract Initialization Vector (IV)
- [Recommendation] Check if the key length is 32 bytes, which is the required size for the AES-256 encryption algorithm.
TypeScript Example
- Extracts the first 32 characters of the encrypted value, which correspond to the initialisation vector (IV) in hexadecimal format. The IV is a random value used to make each encryption unique, even with the same key.
TypeScript Example
- Converts the hexadecimal IV to a byte buffer.
TypeScript Example
2
Extract Encrypted Data
- Extracts the remaining part of the encrypted value, which contains the actual encrypted data.
TypeScript Example
3
Decryption
- Creates a decryptor object using the AES-256 algorithm in CBC (Cipher Block Chaining) mode, the key and the IV.
TypeScript Example
- Start decrypting the data and store the result.
TypeScript Example