diff --git a/demos/auth.c b/demos/auth.c index 6accf7d6..905b8287 100644 --- a/demos/auth.c +++ b/demos/auth.c @@ -50,7 +50,7 @@ auth(void) printf("Generating %s authentication...\n", crypto_auth_primitive()); crypto_auth(mac, message, message_len, key); - fputs("Authentication tag: ", stdout); + printf("Authentication tag: "); print_hex(mac, sizeof mac); puts("Verifying authentication tag..."); diff --git a/demos/box.c b/demos/box.c index 79dc3144..066ac4e4 100644 --- a/demos/box.c +++ b/demos/box.c @@ -70,21 +70,21 @@ box(void) crypto_box_keypair(alice_pk, alice_sk); /* generate Alice's keys */ puts("Bob"); - fputs("Public key: ", stdout); + printf("Public key: "); print_hex(bob_pk, sizeof bob_pk); - fputs("Secret key: ", stdout); + printf("Secret key: "); print_hex(bob_sk, sizeof bob_sk); puts("Alice"); - fputs("Public key: ", stdout); + printf("Public key: "); print_hex(alice_pk, sizeof alice_pk); - fputs("Secret key: ", stdout); + printf("Secret key: "); print_hex(alice_sk, sizeof alice_sk); /* nonce must be unique per (key, message) - it can be public and deterministic */ puts("Generating nonce..."); randombytes_buf(nonce, sizeof nonce); - fputs("Nonce: ", stdout); + printf("Nonce: "); print_hex(nonce, sizeof nonce); /* read input */ @@ -102,9 +102,9 @@ box(void) printf("Ciphertext len: %zu bytes - Original message length: %zu bytes\n", ciphertext_len, message_len); puts("Notice the prepended 16 byte authentication token\n"); - fputs("Nonce: ", stdout); + printf("Nonce: "); print_hex(nonce, nonce_len); - fputs("Ciphertext: ", stdout); + printf("Ciphertext: "); print_hex(ciphertext, ciphertext_len); /* decrypt the message */ diff --git a/demos/box_detached.c b/demos/box_detached.c index 80478b4a..2d8cd3ef 100644 --- a/demos/box_detached.c +++ b/demos/box_detached.c @@ -70,21 +70,21 @@ box_detached(void) crypto_box_keypair(alice_pk, alice_sk); /* generate Alice's keys */ puts("Bob"); - fputs("Public key: ", stdout); + printf("Public key: "); print_hex(bob_pk, sizeof bob_pk); - fputs("Secret key: ", stdout); + printf("Secret key: "); print_hex(bob_sk, sizeof bob_sk); puts("Alice"); - fputs("Public key: ", stdout); + printf("Public key: "); print_hex(alice_pk, sizeof alice_pk); - fputs("Secret key: ", stdout); + printf("Secret key: "); print_hex(alice_sk, sizeof alice_sk); /* nonce must be unique per (key, message) - it can be public and deterministic */ puts("Generating nonce..."); randombytes_buf(nonce, sizeof nonce); - fputs("Nonce: ", stdout); + printf("Nonce: "); print_hex(nonce, sizeof nonce); /* read input */ @@ -99,11 +99,11 @@ box_detached(void) /* send the nonce, the MAC and the ciphertext */ puts("Bob sends the nonce, the MAC and the ciphertext...\n"); - fputs("Nonce: ", stdout); + printf("Nonce: "); print_hex(nonce, sizeof nonce); - fputs("MAC: ", stdout); + printf("MAC: "); print_hex(mac, sizeof mac); - fputs("Ciphertext: ", stdout); + printf("Ciphertext: "); print_hex(ciphertext, message_len); /* decrypt the message */ diff --git a/demos/generichash.c b/demos/generichash.c index 064a3c53..51f5978f 100644 --- a/demos/generichash.c +++ b/demos/generichash.c @@ -68,7 +68,7 @@ generichash(void) key, key_len) != 0) { puts("Couldn't hash the message, probably due to the key length"); } else { - fputs("Hash: ", stdout); + printf("Hash: "); print_hex(hash, sizeof hash); } } diff --git a/demos/generichash_stream.c b/demos/generichash_stream.c index 67d46df3..1db3fc39 100644 --- a/demos/generichash_stream.c +++ b/demos/generichash_stream.c @@ -47,7 +47,7 @@ generichash_stream(void) } crypto_generichash_final(&state, hash, sizeof hash); - fputs("Hash: ", stdout); + printf("Hash: "); print_hex(hash, sizeof hash); } diff --git a/demos/shorthash.c b/demos/shorthash.c index 6aac468c..cc31d711 100644 --- a/demos/shorthash.c +++ b/demos/shorthash.c @@ -47,7 +47,7 @@ shorthash(void) printf("Hashing the message with %s\n", crypto_shorthash_primitive()); crypto_shorthash(hash, message, message_len, key); - fputs("Hash: ", stdout); + printf("Hash: "); print_hex(hash, sizeof hash); } diff --git a/demos/sign.c b/demos/sign.c index 778b33e8..e9c8f007 100644 --- a/demos/sign.c +++ b/demos/sign.c @@ -35,9 +35,9 @@ sign(void) puts("Generating keypair..."); crypto_sign_keypair(pk, sk); /* generate Bob's keys */ - fputs("Public key: ", stdout); + printf("Public key: "); print_hex(pk, sizeof pk); - fputs("Secret key: ", stdout); + printf("Secret key: "); print_hex(sk, sizeof sk); puts("The secret key, as returned by crypto_sign_keypair(), actually includes " "a copy of the public key, in order to avoid a scalar multiplication " @@ -53,9 +53,9 @@ sign(void) printf("A %u bytes signature was prepended to the message\n", crypto_sign_BYTES); - fputs("Signature: ", stdout); + printf("Signature: "); print_hex(message_signed, crypto_sign_BYTES); - fputs("Message: ", stdout); + printf("Message: "); fwrite(message_signed + crypto_sign_BYTES, 1U, message_signed_len - crypto_sign_BYTES, stdout); putchar('\n');