y*****m 发帖数: 723 | 1 要求写一个xor cipher的utility。
要求摘要:“Create a utility that will perform a simple XOR cryptographic
transform on a given set of data. The encryption key will be provided by the
binary data in an arbitrarily-sized external file. The size of the key in
bytes will dictate the "block size." The plaintext data will be given on
stdin, where the utility will then break it into block-sized sections, XOR
it against the key, and write the cypher text to stdout. After each block is
processed, the key should be rotated to the left by one bit to make a new
key. This means that the key will repeat every N blocks, where N is the
number of bits in the key. The plaintext data need not be a multiple of the
block size in length, nor should it be assumed to be ASCII or Unicode text.
It is also valid for the plaintext to be extremely large, far exceeding the
available memory+swap space for the system.
In addition to correctly performing the transform, the utility should be
able to take advantage of multi-core or multi-processor machines by
implementing a multi-threading scheme that processes multiple blocks of
plaintext in parallel.“
问题:
1。如果plaintext的大小(byte)不是keyfile大小的整数倍,怎么进行xor,需要把
plaintext填充成整数倍?
2。怎么让utility能进行多线程运算?这个问题已经超过我的背景知识了。。。
要求用C、C++,各位有什么想法尽量提,谢谢。 |
|