abouttreesummaryrefslogcommitdiff
path: root/examples/Decrypt.c
diff options
context:
space:
mode:
authorPatrick2023-06-19 21:21:16 +0200
committerPatrick2023-06-19 21:21:16 +0200
commitad9d01050b7b6d592a83ce14eeef7068bd981028 (patch)
treef6263c85f4c9905bccb1887e50d2777c61b24405 /examples/Decrypt.c
parentd382d193cb2d550cc769afa76e55823865a39023 (diff)
downloadmatrix_esp_thesis-ad9d01050b7b6d592a83ce14eeef7068bd981028.tar.gz
matrix_esp_thesis-ad9d01050b7b6d592a83ce14eeef7068bd981028.zip
olm session management
Diffstat (limited to 'examples/Decrypt.c')
-rw-r--r--examples/Decrypt.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/examples/Decrypt.c b/examples/Decrypt.c
new file mode 100644
index 0000000..b496780
--- /dev/null
+++ b/examples/Decrypt.c
@@ -0,0 +1,45 @@
+#include <matrix.h>
+#include <stdio.h>
+
+#define SERVER "https://matrix.org"
+#define ACCESS_TOKEN "syt_cHNjaG8_yBvTjVTquGCikvsAenOJ_49mBMO"
+#define DEVICE_ID "MAZNCCZLBR"
+#define ROOM_ID "!koVStwyiiKcBVbXZYz:matrix.org"
+#define EVENT_ID ""
+
+int
+main(void)
+{
+ MatrixClient client;
+ MatrixClientInit(&client,
+ SERVER);
+
+ MatrixHttpInit(&client);
+
+ MatrixClientSetAccessToken(&client,
+ ACCESS_TOKEN);
+
+ static char eventBuffer[1024];
+ MatrixClientGetRoomEvent(&client,
+ ROOM_ID,
+ EVENT_ID,
+ eventBuffer, 1024);
+
+ MatrixMegolmInSession megolmSession;
+
+ MatrixClientRequestMegolmSession(&client,
+ ROOM_ID,
+ EVENT_ID,
+ &megolmSession);
+
+ static char decryptedBuffer[1024];
+ MatrixMegolmSessionDecrypt(&megolmSession,
+ eventBuffer,
+ decryptedBuffer, 1024);
+
+ printf("%s\n", decryptedBuffer);
+
+ MatrixHttpDeinit(&client);
+
+ return 0;
+} \ No newline at end of file