MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Xor

Method Xor

src/streams.h:420–436  ·  view source on GitHub ↗

* XOR the contents of this stream with a certain key. * * @param[in] key The key used to XOR the data in this stream. */

Source from the content-addressed store, hash-verified

418 * @param[in] key The key used to XOR the data in this stream.
419 */
420 void Xor(const std::vector<unsigned char>& key)
421 {
422 if (key.size() == 0) {
423 return;
424 }
425
426 for (size_type i = 0, j = 0; i != size(); i++) {
427 vch[i] ^= key[j++];
428
429 // This potentially acts on very many bytes of data, so it's
430 // important that we calculate `j`, i.e. the `key` index in this
431 // way instead of doing a %, which would effectively be a division
432 // for each byte Xor'd -- much slower than need be.
433 if (j == key.size())
434 j = 0;
435 }
436 }
437};
438
439

Callers 4

WriteMethod · 0.80
GetValueMethod · 0.80
ReadMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 1

sizeMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64