Let's uncomment a code for audio and put an encryption in it.
This commit is contained in:
parent
0c61d4e433
commit
b04fbeb34e
38
src/main.c
38
src/main.c
@ -96,6 +96,28 @@ int main(int argc, char **argv) {
|
|||||||
if (strcmp(msg, rmsg) != 0)
|
if (strcmp(msg, rmsg) != 0)
|
||||||
fprintf(stderr, "Yikes!");
|
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:
|
cleanup:
|
||||||
free(oh);
|
free(oh);
|
||||||
free(rh);
|
free(rh);
|
||||||
@ -112,21 +134,5 @@ cleanup:
|
|||||||
crypt_session_destroy(&os);
|
crypt_session_destroy(&os);
|
||||||
crypt_session_destroy(&rs);
|
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;
|
return rt;
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user