From b04fbeb34ebcf7b2c60bddd22c95e615a07b3cc1 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 24 Mar 2024 06:05:01 +0400 Subject: [PATCH] Let's uncomment a code for audio and put an encryption in it. --- src/main.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index 2b34a59..827443f 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,28 @@ int main(int argc, char **argv) { if (strcmp(msg, rmsg) != 0) fprintf(stderr, "Yikes!"); + audio_t aud; + + unsigned char buf[BUF_SIZE]; + memset(buf, 0, BUF_SIZE); + + audio_init(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER); + + unsigned char *c = NULL, *m = NULL; + unsigned long long cl = 0, ml = 0; + + printf("Listening... "); + for (int i = 0; i < (2 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) { + audio_read(&aud, buf, BUF_SIZE); + c = crypt_session_encrypt(&os, buf, BUF_SIZE, &cl); + m = crypt_session_decrypt(&rs, c, cl, &ml); + audio_write(&aud, m, ml); + free(c); free(m); + } + printf("Done!\n"); + + audio_destroy(&aud); + cleanup: free(oh); free(rh); @@ -112,21 +134,5 @@ cleanup: crypt_session_destroy(&os); crypt_session_destroy(&rs); - // audio_t aud; - - // unsigned char buf[BUF_SIZE]; - // memset(buf, 0, BUF_SIZE); - - // audio_init(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER); - - // printf("Listening... "); - // for (int i = 0; i < (2 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) { - // audio_read(&aud, buf, BUF_SIZE); - // audio_write(&aud, buf, BUF_SIZE); - // } - // printf("Done!\n"); - - // audio_destroy(&aud); - return rt; } \ No newline at end of file