void testFactory(vector<char> data, seconds duration, seconds maxTimeToTest, int id) { Puzzle p; HardwareSpeedTester hst(1000, maxTimeToTest); TimeCapsuleFactory<char> tcf(hst); //char rawdata[] = "Hey, I hope it will finish in time.. tho probably not :D ..."; auto capsule = tcf.createTimeCapsule(p, data, duration); capsule.save("capsule_" + to_string(id) + ".dat"); Capsule<char> capsule2; capsule2.load("capsule_" + to_string(id) + ".dat"); auto crdata = capsule.getCryptedData(); auto crdata2 = capsule2.getCryptedData(); assert(capsule.getBase() == capsule2.getBase()); assert(capsule.getN() == capsule2.getN()); assert(capsule.getIV() == capsule2.getIV()); assert(capsule.getCryptedKey() == capsule2.getCryptedKey()); assert(capsule.getNumberOfOperations() == capsule2.getNumberOfOperations()); Logger::log("Original crypted data size: " + to_string(crdata.size())); Logger::log("Copypasted crypted data size: " + to_string(crdata2.size())); string datastr(crdata.begin(), crdata.end()); string datastr2(crdata2.begin(), crdata2.end()); Logger::log("Original crypted data: " + datastr); Logger::log("Copypasted crypted data: " + datastr2); //cout << capsule.getCryptedData().size() << ", " << capsule2.getCryptedData().size() << endl; //assert(capsule.getCryptedData().size() == capsule2.getCryptedData().size()); //for (size_t i = 0; i < capsule.getCryptedData().size(); ++i) // assert(capsule.getCryptedData()[i] == capsule2.getCryptedData()[i]); Puzzle p2(capsule2.getBase()); auto start = chrono::high_resolution_clock::now(); auto key = p2.solve(capsule2.getCryptedKey(), capsule2.getNumberOfOperations(), capsule2.getN()); auto end = chrono::high_resolution_clock::now(); Logger::log("Time specified to decode: " + to_string(duration.count()) + " seconds"); Logger::log("Time taken to decode: " + to_string(chrono::duration_cast<seconds>(end - start).count()) + " seconds"); Encryptor<char> cr; auto databack = cr.decrypt(capsule2.getCryptedData(), key, capsule2.getIV()); string tmpdata(data.begin(), data.end()); string tmpdataback(databack.begin(), databack.end()); Logger::log("Original data: " + tmpdata); Logger::log("Data decrypted: " + tmpdataback); /*char dummychar; if (crdata.size() != crdata2.size()) { Logger::log("PARA VAN!"); cin >> dummychar; }*/ }
// Create Objects void TestScene::SetupObjects() { spObject sun(new Object); sun->SetVO(MakeShareable(new PrimitiveUVSphere(256, 128))); sun->GetTransform().SetScale(Vector3(2.f, 2.f, 2.f)); Texture sunTexture; LoadTexture(sunTexture, "textures/texture_sun.png"); sun->GetVO()->GetTexture() = sunTexture; sun->SetGLMode(GL_TRIANGLES); sun->EnableTexture(); sun->SetName(L"Sun"); objects.push_back(sun); objectMap.insert(std::make_pair(sun->GetName(), sun)); spObject world(new Object); world->SetVO(MakeShareable(new PrimitiveUVSphere(256, 128))); world->GetTransform().SetPosition(Vector3(5.f, 0.f, 0.f)); Texture worldTexture; LoadTexture(worldTexture, "textures/4kworld.png"); world->GetVO()->GetTexture() = worldTexture; world->SetGLMode(GL_TRIANGLES); world->EnableTexture(); world->SetName(L"Earth"); world->SetParent(sun.Get(), TransformInheritance(true, false, true, false)); objects.push_back(world); objectMap.insert(std::make_pair(world->GetName(), world)); spObject clouds(new Object); clouds->SetVO(MakeShareable(new PrimitiveUVSphere(256, 128))); clouds->GetTransform().SetScale(Vector3(1.01f, 1.01f, 1.01f)); Texture cloudTexture; LoadTexture(cloudTexture, "textures/clouds.png"); clouds->GetVO()->GetTexture() = cloudTexture; clouds->SetGLMode(GL_TRIANGLES); clouds->EnableTexture(); clouds->EnableTransparency(); clouds->SetName(L"Clouds"); clouds->SetParent(world.Get(), TransformInheritance(true, false, true, false)); objects.push_back(clouds); objectMap.insert(std::make_pair(clouds->GetName(), clouds)); //spObject disc(new Object); //disc->SetVO(new PrimitiveDisc(64)); //Texture discTexture; //LoadTexture(discTexture, "crate.png"); //disc->GetVO()->GetTexture() = discTexture; //disc->SetGLMode(GL_TRIANGLE_FAN); //disc->GetTransform().SetPosition(Vector3(2.5f, 0.0f, 0.0f)); //disc->EnableTexture(); //disc->SetName(L"Disc"); //objects.push_back(disc); spObject moon(new Object); moon->SetVO(MakeShareable(new PrimitiveUVSphere(256, 128))); moon->GetTransform().SetScale(Vector3(0.27f, 0.27f, 0.27f)); moon->GetTransform().SetPosition(Vector3(0.f, 0.f, -2.2f)); Texture moonTexture; LoadTexture(moonTexture, "textures/moonmap1k.png"); moon->GetVO()->GetTexture() = moonTexture; moon->SetGLMode(GL_TRIANGLES); moon->EnableTexture(); moon->SetName(L"Moon"); moon->SetParent(world.Get(), TransformInheritance(true, false, true, false)); objects.push_back(moon); objectMap.insert(std::make_pair(moon->GetName(), moon)); spObject hst(new Object); hst->SetVO(MakeShareable(new Model)); static_cast<Model*>(hst->GetVO().Get())->Load("models/hst.obj", "textures/hst.png"); hst->GetTransform().SetScale(Vector3(0.0001f, 0.0001f, 0.0001f)); // This thing is yuge! hst->GetTransform().SetPosition(Vector3(-1.1f, 0.f, 0.f)); hst->GetTransform().SetPreRotation(Rotation(0.f, Vector3(0.25f, 0.25f, -0.25f))); hst->GetTransform().SetRotation(Rotation(0.f, Vector3(-0.2f, 0.8f, -0.2f))); hst->SetGLMode(GL_TRIANGLES); hst->SetName(L"HST"); hst->EnableTexture(); hst->SetParent(world.Get(), TransformInheritance(true, false, true, false)); objects.push_back(hst); objectMap.insert(std::make_pair(hst->GetName(), hst)); spObject iss(new Object); iss->SetVO(MakeShareable(new Model)); static_cast<Model*>(iss->GetVO().Get())->Load("models/iss.obj", "textures/iss.png"); iss->GetTransform().SetScale(Vector3(0.01f, 0.01f, 0.01f)); iss->GetTransform().SetPreRotation(Rotation(0.f, Vector3(0.f, 0.5f, 0.f))); iss->GetTransform().SetRotation(Rotation(0.f, Vector3(0.25f, 0.5f, 0.25f))); iss->GetTransform().SetPosition(Vector3(0.f, 0.f, 1.2f)); iss->SetGLMode(GL_TRIANGLES); iss->SetName(L"ISS"); iss->EnableTexture(); iss->SetParent(world.Get(), TransformInheritance(true, false, true, false)); objects.push_back(iss); objectMap.insert(std::make_pair(iss->GetName(), iss)); spObject teapot(new Object); teapot->SetVO(MakeShareable(new Model)); static_cast<Model*>(teapot->GetVO().Get())->Load("Models/teapot.obj", "textures/teapot.png"); teapot->GetTransform().SetPosition(Vector3(5.f, 5.f, -3.f)); teapot->GetTransform().SetPreRotation(Rotation(0.f, Vector3(1.f, 0.f, 0.f))); teapot->GetTransform().SetRotation(Rotation(0.f, Vector3(0.f, 0.f, 1.f))); teapot->GetTransform().SetScale(Vector3(0.05f, 0.05f, 0.05f)); teapot->SetGLMode(GL_TRIANGLES); teapot->SetName(L"Teapot"); teapot->EnableTexture(); teapot->SetParent(iss.Get(), TransformInheritance(true, true, true, false)); objects.push_back(teapot); objectMap.insert(std::make_pair(teapot->GetName(), teapot)); }