*/
#include "base/rebase.hpp"
-#define WITH_TRACE
+//#define WITH_TRACE
#include "retrace.hpp"
enum {
LOC_READ_1 = LOC_FIRST_OF(LOC_RANDOMIZER), // 12201
QByteArray& info)
{
TRACE("initFromHeader():\n");
- encryptedFrom = max(encryptedFrom, encryptedFrom < (int) sizeof(int64_t)
+ encryptedFrom = max(encryptedFrom, (int) sizeof(int64_t)
+ reservedLength + markerLength);
bool rc = true;
if (header == NULL)
} else {
m_salt.fromBytes(reinterpret_cast<const uint8_t*>(header->constData()));
randomReset();
- TRACE1("salt: %08lx\n", m_salt.m_int);
+ TRACE2("salt: %08lx / %s\n", m_salt.m_int, hexBytes(m_salt.m_bytes, 8).constData());
QByteArray expectedMarker;
if (markerLength > 0)
m_contentRandom.nextString(markerLength, markerLength, expectedMarker);
int infoLength, int encryptedFrom, const QByteArray& info)
{
TRACE("initHeader():\n");
- encryptedFrom = max(encryptedFrom, encryptedFrom < (int) sizeof(int64_t)
- + reservedLength + markerLength);
+ encryptedFrom = max(encryptedFrom,
+ (int) sizeof(int64_t) + reservedLength + markerLength);
m_salt.m_int = ReRandomizer::nearTrueRandom();
m_contentRandom.reset();
m_contentRandom.modifySeed(m_salt.m_int);
m_buffer, markerLength);
TRACE1("marker: %s\n", m_buffer.constData());
}
+ TRACE1("header-2 %s\n", hexBytes(m_header.constData(), 8).constData());
char* trg;
if (info.length() > 0){
int offset = sizeof(int64_t) + reservedLength + markerLength;
trg = reinterpret_cast<char*>(m_header.data() + offset);
memcpy(trg, info, min(m_header.length() - offset, info.length()));
}
+ TRACE1("header-3 %s\n", hexBytes(m_header.constData(), 8).constData());
if (encryptedFrom < m_header.length()){
randomReset();
uint8_t* start = reinterpret_cast<uint8_t*>(m_header.data() + encryptedFrom);
* @param start first index to encode/decode. The data lying in front
* will be copied
*/
- inline void codec(QByteArray& target, const QByteArray source, int start = 0){
+ inline void codec(QByteArray& target, const QByteArray& source, int start = 0){
target.resize(source.length());
if (start > 0)
memcpy((uint8_t*)target.data(), (const uint8_t*) source.constData(),
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+/** @file
+ * @brief Unit test of the byte and C string storage.
+ */
+
+#include "base/rebase.hpp"
+
+class TestReProcess: public ReTest {
+public:
+ TestReProcess() :
+ ReTest("ReProcess") {
+ doIt();
+ }
+private:
+ void testExecAndRead() {
+#if defined __linux__
+ QStringList args;
+ args.append("-u");
+ QByteArray id = ReProcess::executeAndRead(QString("/usr/bin/id"), args);
+ checkF(id.isEmpty());
+
+#else
+#error "missing test"
+#endif
+ }
+
+public:
+ virtual void run() {
+ testExecAndRead();
+ }
+};
+void testReProcess() {
+ TestReProcess test;
+}
+
+
+
+
}
src = "12345678abcdefghijklmn";
QByteArray trg;
- scrambler.contentRandom(true).codec(src, trg, 8);
+ scrambler.contentRandom(true).codec(trg, src, 8);
checkEqu("12345678", trg.mid(0, 8));
src = "1234XY78abcdefghijklmn";
QByteArray trg2;
- scrambler.contentRandom(true).codec(src, trg2, 8);
+ scrambler.contentRandom(true).codec(trg2, src, 8);
checkEqu("1234XY78", trg2.mid(0, 8));
checkEqu(trg.mid(8), trg2.mid(8));
}