Partial Outageshare-external
En/Decrypt with php Flows
2

Hi,

I was looking at the site:

https://developers.facebook.com/docs/whatsapp/flows/reference/implementingyourflowendpoint#request-decryption

I was wondering... Does anyone already have some example code for en/decrypting in PHP? The current examples are Java(script) and python.

Best regards and thanks in advance, Freek

Freek
Asked about 6 months ago
Selected Answer
1

Thanks for your question. We have added a PHP example in the endpoint documentation page now https://developers.facebook.com/docs/whatsapp/flows/guides/implementingyourflowendpoint#php-slim-example

Please let us know if you face other issues

November 7 at 4:55 AM
Mostafa
Selected Answer
1

Hi, i am also currently struggling to implement the enc/decryption in php. I have tried out the python sample too, but it seems it doesn't seem to work. Let me know if you find anything

November 5 at 10:39 PM
Arsi
Mostafa

We have added a PHP example now https://developers.facebook.com/docs/whatsapp/flows/guides/implementingyourflowendpoint#php-slim-example

Can you explain the problem you had with the python sample?

November 7 at 4:55 AM
Arsi

Here is the like that produces the error.

private_key = load_pem_private_key( PRIVATE_KEY.encode('utf-8'), str.encode("mypasswordhere"),default_backend()) # print("private key is {}".type(private_key)) aes_key = private_key.decrypt(encrypted_aes_key, OAEP( mgf=MGF1(algorithm=hashes.SHA256()), algorithm=hashes.SHA256(), label=None))

```Traceback (most recent call last):

. . . File "/Users/username/PycharmProjects/whatsappflow/venv/lib/python3.9/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 163, in _enc_dec_rsa_pkey_ctx raise ValueError("Encryption/decryption failed.") ValueError: Encryption/decryption failed.

i do not have a good grasp on python to further debug it. I have encountered similar issues with the nodejs sample too (I do not remember the exact issue that pops up). Will look into the php samples you provided. Thanks for the link

November 7 at 3:28 PM
Arsi

@Mostafa - I could not include the whole debug because it was detected as a content violating content. I dont understand why tho

November 7 at 3:29 PM