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
Đã hỏi khoảng 7 tháng trước
Câu trả lời được chọn
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

7 tháng 11 lúc 04:55
Mostafa
Câu trả lời được chọn
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

5 tháng 11 lúc 22:39
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?

7 tháng 11 lúc 04:55
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

7 tháng 11 lúc 15:28
Arsi

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

7 tháng 11 lúc 15:29