abouttreesummaryrefslogcommitdiff
path: root/examples/Decrypt.c
blob: b496780ff01ad0a9ec6ccaf4423d6278a169097c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}