As I am using woocommerce webhooks , I am asking about secret key as It is not described well in the woocommerce docs how to verify the data integrity using the secret key

This is the code snippet but signature is always not equal to hashInbase64

 const secret = '123abc'
 const signature = req.header("X-WC-Webhook-Signature")
 var hash = CryptoJS.HmacSHA256(req.body, secret)
 var hashInBase64 = CryptoJS.enc.Base64.stringify(hash)
  • Do you have examples where it is equal and where it isn't? Is there any obvious difference, e.g. the line endings, whitespace if this is formatted JSON? You might need to make sure you're hashing the body before node.js processes it, e.g. stackoverflow.com/q/18710225/243245 – Rup Jul 15 '19 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.