1
0
Fork 0

Let's uncomment a code for audio and put an encryption in it.

This commit is contained in:
Alexander Andreev 2024-03-24 06:05:01 +04:00
parent 0c61d4e433
commit b04fbeb34e
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
1 changed files with 22 additions and 16 deletions

View File

@ -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;
}