[SOLVED] CS代考计算机代写 /* Encrypts, then decrypts, 2 MB of memory and verifies that the

30 $

File Name: CS代考计算机代写_/*_Encrypts,_then_decrypts,_2_MB_of_memory_and_verifies_that_the.zip
File Size: 828.96 KB

SKU: 3504740413 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


/* Encrypts, then decrypts, 2 MB of memory and verifies that the
values are as they should be. */

#include
#include “tests/arc4.h”
#include “tests/lib.h”
#include “tests/main.h”

#define SIZE (2 * 1024 * 1024)

static char buf[SIZE];

void
test_main (void)
{
struct arc4 arc4;
size_t i;

/* Initialize to 0x5a. */
msg (“initialize”);
memset (buf, 0x5a, sizeof buf);

/* Check that it’s all 0x5a. */
msg (“read pass”);
for (i = 0; i < SIZE; i++)if (buf[i] != 0x5a)fail (“byte %zu != 0x5a”, i);/* Encrypt zeros. */msg (“read/modify/write pass one”);arc4_init (&arc4, “foobar”, 6);arc4_crypt (&arc4, buf, SIZE);/* Decrypt back to zeros. */msg (“read/modify/write pass two”);arc4_init (&arc4, “foobar”, 6);arc4_crypt (&arc4, buf, SIZE);/* Check that it’s all 0x5a. */msg (“read pass”);for (i = 0; i < SIZE; i++)if (buf[i] != 0x5a)fail (“byte %zu != 0x5a”, i);}

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代考计算机代写 /* Encrypts, then decrypts, 2 MB of memory and verifies that the
30 $