Skip to content

GrantMoe/crypto-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"Simple Parallel Crypto"

We need a utility that will perform a simple XOR crypto transform. They key will be given as a set of bytes in an external file and the number of bytes in the key will dictate the "chunk size". The plain text data will be given on stdin and the utility must break it into chunk-size sections and XOR it against the key and write the cypher text it to stdout. After each chunk is processed the key is rotated left by one bit to make a new key. This means that the key will repeat every N chunks, where N is the number of bits in the key. The plain text may not be a multiple of the chunk size in length. The plain text may also be very large, far exceeding the available memory+swap space in the system.

In addition to just performing the algorithm, the utility needs to scale so that multiple chunks of plain text can be efficiently processed in parallel on multi-core/multi-CPU machines. As such, a number of threads must be created to process chunks of data concurrently. Regardless of the number of threads, the output cypher text must remain the same.

Any errors/status must come out on stderr.

Required Command Line Options: -k Specify the key file -n # Number of threads to create

Example: The keyfile contains two bytes: 0xF0 0xF0 The plain text file has the bytes: 0x01 0x02 0x03 0x04 0x11 0x12 0x13 0x14

encrypt -k keyfile -n 1 < plain > cypher

The cypher text has the bytes: 0xF1 0xF2 0xE2 0xE5 0xD2 0xD1 0x94 0x93

Implementation Details/Notes:

The utility can be written in either Java or C/C++. If Java, it should build and run inside of Eclipse. If C/C++, it should build and run on a POSIX system (like Linux or Mac OS X). A good way to generate keyfiles and plain text files is as follows:

dd if=/dev/urandom of=plain bs=4096 count=4096 dd if=/dev/random of=keyfile bs=4096 count=1

About

A technical challenge from my uncle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published